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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ļŌµˆmN9$ ęÅØlO4ļÜÅ¢…fO4 ģĻŗ„’y`‚Ń<Ø2€q]s”Š4<# u 8 create proc [dbo].[RemoveSegmentedMapping] @DeleteCountPermanentChunk int, @DeleteCountPermanentMapping int, @DeleteCountTempChunk int, @DeleteCountTempMapping int, @MachineName nvarchar(260) as begin SET DEADLOCK_PRIORITY LOW declare @deleted table ( ChunkID uniqueidentifier, IsPermanent bit ); -- details on lock hints: -- we use readpast on ChunkSegmentMapping to skip past -- rows which are currently locked. they are being actively -- used so clearly we do not want to delete them. we use -- nolock on SegmentedChunk table as well, this is because -- regardless of whether or not that row is locked, we want to -- know if it is referenced by a SegmentedChunk and if -- so we do not want to delete the mapping row. ChunkIds are -- only modified when creating a shallow chunk copy(see ShallowCopyChunk), -- but in this case the ChunkSegmentMapping row is locked (via the insert) -- so we are safe. declare @toDeletePermChunks table ( SnapshotDataId uniqueidentifier ) ; insert into @toDeletePermChunks (SnapshotDataId) select top (@DeleteCountPermanentChunk) SnapshotDataId from SegmentedChunk with (readpast) where not exists ( select 1 from SnapshotData SD with (nolock) where SegmentedChunk.SnapshotDataId = SD.SnapshotDataID ) ; delete from SegmentedChunk with (readpast) where SegmentedChunk.SnapshotDataId in ( select td.SnapshotDataId from @toDeletePermChunks td where not exists ( select 1 from SnapshotData SD where td.SnapshotDataId = SD.SnapshotDataID )) ; -- clean up segmentedchunks from permanent database declare @toDeleteChunks table ( ChunkId uniqueidentifier ); -- clean up mappings from permanent database insert into @toDeleteChunks (ChunkId) select top (@DeleteCountPermanentMapping) ChunkId from ChunkSegmentMapping with (readpast) where not exists ( select 1 from SegmentedChunk SC with (nolock) where SC.ChunkId = ChunkSegmentMapping.ChunkId ) ; delete from ChunkSegmentMapping with (readpast) output deleted.ChunkId, convert(bit, 1) into @deleted where ChunkSegmentMapping.ChunkId in ( select td.ChunkId from @toDeleteChunks td where not exists ( select 1 from SegmentedChunk SC where SC.ChunkId = td.ChunkId ) and not exists ( select 1 from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk TSC where TSC.ChunkId = td.ChunkId ) ) declare @toDeleteTempChunks table ( SnapshotDataId uniqueidentifier); -- clean up SegmentedChunks from the Temp database -- for locking we play the same idea as in the previous query. -- snapshotIds never change, so again this operation is safe. insert into @toDeleteTempChunks (SnapshotDataId) select top (@DeleteCountTempChunk) SnapshotDataId from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk with (readpast) where [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk.Machine = @MachineName and not exists ( select 1 from [ReportServer$SQLEXPRESSTempDB].dbo.SnapshotData SD with (nolock) where [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk.SnapshotDataId = SD.SnapshotDataID ) ; delete from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk with (readpast) where [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk.SnapshotDataId in ( select td.SnapshotDataId from @toDeleteTempChunks td where not exists ( select 1 from [ReportServer$SQLEXPRESSTempDB].dbo.SnapshotData SD where td.SnapshotDataId = SD.SnapshotDataID )) ; declare @toDeleteTempMappings table ( ChunkId uniqueidentifier ); -- clean up mappings from temp database insert into @toDeleteTempMappings (ChunkId) select top (@DeleteCountTempMapping) ChunkId from [ReportServer$SQLEXPRESSTempDB].dbo.ChunkSegmentMapping with (readpast) where not exists ( select 1 from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk SC with (nolock) where SC.ChunkId = [ReportServer$SQLEXPRESSTempDB].dbo.ChunkSegmentMapping.ChunkId ) ; delete from [ReportServer$SQLEXPRESSTempDB].dbo.ChunkSegmentMapping with (readpast) output deleted.ChunkId, convert(bit, 0) into @deleted where [ReportServer$SQLEXPRESSTempDB].dbo.ChunkSegmentMapping.ChunkId in ( select td.ChunkId from @toDeleteTempMappings td where not exists ( select 1 from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk SC where td.ChunkId = SC.ChunkId )) ; -- need to return these so we can cleanup file system chunks select distinct ChunkID, IsPermanent from @deleted ; end <ł@ E8 CREATE PROCEDURE [dbo].[ListTasks] @Path nvarchar (425) = NULL, @Prefix nvarchar (425) = NULL AS select S.[ScheduleID], S.[Name], S.[StartDate], S.[Flags], S.[NextRunTime], S.[LastRunTime], S.[EndDate], S.[RecurrenceType], S.[MinutesInterval], S.[DaysInterval], S.[WeeksInterval], S.[DaysOfWeek], S.[DaysOfMonth], S.[Month], S.[MonthlyWeek], S.[State], S.[LastRunStatus], S.[ScheduledRunTimeout], S.[EventType], S.[EventData], S.[Type], S.[Path], SUSER_SNAME(Owner.[Sid]), Owner.[UserName], Owner.[AuthType], (select count(*) from ReportSchedule where ReportSchedule.ScheduleID = S.ScheduleID) from [Schedule] S inner join [Users] Owner on S.[CreatedById] = Owner.UserID where S.[Type] = 0 /*Type 0 is shared schedules*/ and ((@Path is null) OR (S.Path = @Path) or (S.Path like @Prefix escape '*')) <Ļų  †8 create proc [dbo].[OpenSegmentedChunk] @SnapshotId uniqueidentifier, @IsPermanent bit, @ChunkName nvarchar(260), @ChunkType int, @ChunkId uniqueidentifier out, @ChunkFlags tinyint out as begin if (@IsPermanent = 1) begin select @ChunkId = ChunkId, @ChunkFlags = ChunkFlags from dbo.SegmentedChunk chunk where chunk.SnapshotDataId = @SnapshotId and chunk.ChunkName = @ChunkName and chunk.ChunkType = @ChunkType select csm.SegmentId, csm.LogicalByteCount as LogicalSegmentLength, csm.ActualByteCount as ActualSegmentLength from ChunkSegmentMapping csm where csm.ChunkId = @ChunkId order by csm.StartByte asc end else begin select @ChunkId = ChunkId, @ChunkFlags = ChunkFlags from [ReportServer$SQLEXPRESSTempDB].dbo.SegmentedChunk chunk where chunk.SnapshotDataId = @SnapshotId and chunk.ChunkName = @ChunkName and chunk.ChunkType = @ChunkType if @ChunkFlags & 0x4 > 0 begin -- Shallow copy: read chunk segments from catalog select csm.SegmentId, csm.LogicalByteCount as LogicalSegmentLength, csm.ActualByteCount as ActualSegmentLength from ChunkSegmentMapping csm where csm.ChunkId = @ChunkId order by csm.StartByte asc end else begin -- Regular copy: read chunk segments from temp db select csm.SegmentId, csm.LogicalByteCount as LogicalSegmentLength, csm.ActualByteCount as ActualSegmentLength from [ReportServer$SQLEXPRESSTempDB].dbo.ChunkSegmentMapping csm where csm.ChunkId = @ChunkId order by csm.StartByte asc end end end 0“• ö8 CREATE PROCEDURE [dbo].[DeleteDataSets] @ItemID [uniqueidentifier] AS DELETE FROM [DataSets] WHERE [ItemID] = @ItemID DELETE FROM [ReportServer$SQLEXPRESSTempDB].dbo.TempDataSets WHERE [ItemID] = @ItemID and ((@Path is null) OR (S.Path = @Path) or (S.Path like @Prefix escape '*')) D = @BatchID 0MŽ…  ž8 CREATE PROCEDURE [dbo].[CleanBatchRecords] @MaxAgeMinutes int AS DELETE FROM [Batch] where BatchID in ( SELECT BatchID FROM [Batch] WHERE AddedOn < DATEADD(minute, -(@MaxAgeMinutes), GETUTCDATE()) ) CT [Name], [Value] FROM [ConfigurationInfo] WL<~ś =õv&§ l ę™ūˆˆˆˆˆˆˆVž<<< Z<ö}ž¦¤(^€+„Š,…/8!€Œ!!!!¾` Zö‚ Ų׍ŒŠ^*8