Stored Procedures [dbo].[CreateSession]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@SessionIDvarchar(32)32
@CompiledDefinitionuniqueidentifier16
@SnapshotDataIDuniqueidentifier16
@IsPermanentSnapshotbit1
@ReportPathnvarchar(440)880
@Timeoutint4
@AutoRefreshSecondsint4
@DataSourceInfoimage16
@OwnerNamenvarchar(260)520
@OwnerSidvarbinary(85)85
@AuthTypeint4
@EffectiveParamsntext16
@HistoryDatedatetime8
@PageHeightfloat8
@PageWidthfloat8
@TopMarginfloat8
@BottomMarginfloat8
@LeftMarginfloat8
@RightMarginfloat8
@AwaitingFirstExecutionbit1
Permissions
TypeActionOwning Principal
GrantExecuteRSExecRole
SQL Script
-- Writes or updates session record
CREATE PROCEDURE [dbo].[CreateSession]
@SessionID as varchar(32),
@CompiledDefinition as uniqueidentifier = NULL,
@SnapshotDataID as uniqueidentifier = NULL,
@IsPermanentSnapshot as bit = NULL,
@ReportPath as nvarchar(440) = NULL,
@Timeout as int,
@AutoRefreshSeconds as int = NULL,
@DataSourceInfo as image = NULL,
@OwnerName as nvarchar (260),
@OwnerSid as varbinary (85) = NULL,
@AuthType as int,
@EffectiveParams as ntext = NULL,
@HistoryDate as datetime = NULL,
@PageHeight as float = NULL,
@PageWidth as float = NULL,
@TopMargin as float = NULL,
@BottomMargin as float = NULL,
@LeftMargin as float = NULL,
@RightMargin as float = NULL,
@AwaitingFirstExecution as bit = NULL
AS
UPDATE PS
SET PS.RefCount = 1
FROM
    [ReportServerTempDB].dbo.PersistedStream as PS
WHERE
    PS.SessionID = @SessionID    
    
UPDATE SN
SET TransientRefcount = TransientRefcount + 1
FROM
   SnapshotData AS SN
WHERE
   SN.SnapshotDataID = @SnapshotDataID
   
UPDATE SN
SET TransientRefcount = TransientRefcount + 1
FROM
   [ReportServerTempDB].dbo.SnapshotData AS SN
WHERE
   SN.SnapshotDataID = @SnapshotDataID
DECLARE @OwnerID uniqueidentifier
EXEC GetUserID @OwnerSid, @OwnerName, @AuthType, @OwnerID OUTPUT
DECLARE @now datetime
SET @now = GETDATE()
INSERT
   INTO [ReportServerTempDB].dbo.SessionData (
      SessionID,
      CompiledDefinition,
      SnapshotDataID,
      IsPermanentSnapshot,
      ReportPath,
      Timeout,
      AutoRefreshSeconds,
      Expiration,
      DataSourceInfo,
      OwnerID,
      EffectiveParams,
      CreationTime,
      HistoryDate,
      PageHeight,
      PageWidth,
      TopMargin,
      BottomMargin,
      LeftMargin,
      RightMargin,
      AwaitingFirstExecution )
   VALUES (
      @SessionID,
      @CompiledDefinition,
      @SnapshotDataID,
      @IsPermanentSnapshot,
      @ReportPath,
      @Timeout,
      @AutoRefreshSeconds,
      DATEADD(s, @Timeout, @now),
      @DataSourceInfo,
      @OwnerID,
      @EffectiveParams,
      @now,
      @HistoryDate,
      @PageHeight,
      @PageWidth,
      @TopMargin,
      @BottomMargin,
      @LeftMargin,
      @RightMargin,
      @AwaitingFirstExecution )
      

GO
GRANT EXECUTE ON  [dbo].[CreateSession] TO [RSExecRole]
GO
Uses