Forum Discussion
How Data Refresh programmatically?
- 3 years ago
lbendlin wrote:
I never know if a question posted in the report server section is actually related to report server. The "catalog" wording should have been my hint to leave this alone as I have no experience with report server.
🙂 it can be hard to tell. A lot of people do not differentiate between "Server" and "Service"
lbendlin wrote:
Is there a way to use the SQL scheduler?
Not easily, the SQL agent jobs are created with Schedule GUID so you are faced with the orignal issue of having to link a ScheduleID and a catalog item
You can alternatively run an SQL Query to do that and call it from PowerShell. We do it directly with SQL in some agent jobs since we want to refresh after certain updates in the database for our datawarehouse. We have a custom view with all subscriptions and relative agent jobs and then it's very easy to trigger subscriptions and schedule refresh this way:
DECLARE @SQLAgent_Job_Name NVARCHAR(36) = (
SELECT [SQLAgent_Job_Name]
FROM [Reports].[AllSubscriptionsAndJobs]
WHERE ReportName = 'Your report name in Report Server / PBRS'
)
EXEC msdb.dbo.sp_start_job job_name = @SQLAgent_Job_Name