Cache Report via SQL commands

  • Hello,
    I'd like to cache a few reports at the same time using a SQL statement.
    Currently I have to go to each SSRS report-->Manage-->Caching-->Click "Create a cache snapshot when I click Apply on this page" --> Apply
    I am looking at some kind of SQL code that I can use to execute that will then caching the report on demand.

    I do something similar with SQL and executing subscriptions to run right now, without having to go to the report itself, change the subscription time, wait a minute, then put it back.

    Thank you.

  • evan.penalba - Friday, December 8, 2017 12:40 PM

    Hello,
    I'd like to cache a few reports at the same time using a SQL statement.
    Currently I have to go to each SSRS report-->Manage-->Caching-->Click "Create a cache snapshot when I click Apply on this page" --> Apply
    I am looking at some kind of SQL code that I can use to execute that will then caching the report on demand.

    I do something similar with SQL and executing subscriptions to run right now, without having to go to the report itself, change the subscription time, wait a minute, then put it back.

    Thank you.

    If you are going to refresh a cached report, It's the same with executing ReportServer.dbo.AddEvent.
    EventType is 'RefreshCache' and EventData is subscription id.

    However, you are talking about a snapshot, not a cached report - the wording on that in Report Manager is a bit confusing. If you wanted to be able to create a snapshot on demand, you would probably want to schedule time to create the report snapshot. Then you can update that on demand using the same - executing AddEvent.
    EventType is 'ReportExecutionUpdateSchedule' and EventData is the report id.

    Sue

  • Thank you. I was able to get close to what I was trying to do, but does not seem to be kicking off the Cache refresh. My logic below:

    ---Find the Schedule ID for the report in question.
    select [ScheduleID]
      ,[ReportID]
      ,[SubscriptionID]
      ,[ReportAction]
         , c.Name
    FROM [ReportServer].[dbo].[ReportSchedule] r
    left join Catalog c on c.ItemID = r.ReportID
     where
            c.Path like '%/xyz/%'
            and r.ReportAction <> 4 --eliminate Email Subscriptions
            and c.name in (
                'Report Name - ABC'
                )

    ---- Execute the cache for that report.
    exec ReportServer.dbo.AddEvent @EventType = 'RefreshCache'
    , @EventData = 'FC792F92-2FB3-4D81-BA3D-C9ABCF6EF90C' -- ScheduleID from the 'ReportSchedule' results

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply