Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过特定报表的SQL查询在SSRS报表中创建新快照_Sql_Reporting Services - Fatal编程技术网

如何通过特定报表的SQL查询在SSRS报表中创建新快照

如何通过特定报表的SQL查询在SSRS报表中创建新快照,sql,reporting-services,Sql,Reporting Services,通过用户界面单击new snapshot(新建快照)按钮,可以很容易地在报表服务器上为报表创建快照,但我只需要使用SQL查询来创建新的快照。这意味着什么是SQL查询,我可以通过它为报表服务器上的特定报表创建新快照,而无需使用用户界面?不鼓励直接点击ReportServer数据库。生成SSRS报告快照的首选方法是使用C#调用API方法。但是,如果必须使用SQL,请查看AddEventReportServer存储过程 exec [ReportServer].dbo.AddEvent @EventTy

通过用户界面单击new snapshot(新建快照)按钮,可以很容易地在报表服务器上为报表创建快照,但我只需要使用SQL查询来创建新的快照。这意味着什么是SQL查询,我可以通过它为报表服务器上的特定报表创建新快照,而无需使用用户界面?不鼓励直接点击ReportServer数据库。生成SSRS报告快照的首选方法是使用C#调用API方法。但是,如果必须使用SQL,请查看
AddEvent
ReportServer存储过程

exec [ReportServer].dbo.AddEvent @EventType='ReportExecutionUpdateSchedule', @EventData='<InsertReportIDHere>'

这很紧急。谢谢,我认为这是行不通的。您正在尝试使用SQL管理报表服务器。SQL Server旨在管理数据而不是应用程序。
declare @Path varchar(425)
set @Path = '/SSRS Testing and Training/Test_snapshot' -- the name of my linked report which renders from a snapshot

declare @EventData uniqueidentifier
select @EventData = (select ItemID from Catalog where Path = @Path) 

-- make a new snapshot in History table
exec ReportServer.dbo.AddEvent 'ReportHistorySchedule', @EventData 

-- !!!! wait until Reporting Services figures out that it has an event to process (it actually takes 5sec)
waitfor delay '00:00:10' 

-- take a snapshot ID from a newly created row in History table
declare @SnapshotDataID uniqueidentifier
select @SnapshotDataID = (select SnapshotDataID from history WHERE ReportID = @EventData)

-- set a date for a new Snapshot in Catalog table
-- use getdate() instead (select SnapshotDate from history WHERE ReportID = @EventData) because otherwise you'll get a UTC date for "last run date" in Report Manager which can confuse your users 
declare @SnapshotDate datetime
select @SnapshotDate = getdate() 

-- run a RS stored procedure which updates SnapshotDataID in Catalog table and some other necessary things
exec UpdateSnapshot @Path,@SnapshotDataID,@SnapshotDate