Question

I want to refresh a table using a SSIS package every time the user runs a report built out of Report Builder 3.0, so I've created a SSIS job and call sp_start_job from Report Builder as a stored procedure to invoke this job.

This all works fine, but the report doesn't wait for the job to finish before populating the dataset (I can tell because I have a "last refresh date" column in my table).

Is there a way to make sure the job finishes before the data gets loaded into the report itself?

Edit: So I decided to try calling the job and waiting before the SELECT statement like this:

USE msdb;

EXECUTE dbo.sp_start_job N'CUBE - IS Inventory Report Refresh'

WAITFOR DELAY '00:00:25'

USE OtherDatabase;

SELECT  ...

but the timestamp is still showing an older date. The SSIS job runs in 17 seconds (from the history logs), so waiting for 25 seconds before I select from the table should be plenty... does anyone have insight on why this is happening?

When I run the query in Management Studio, the table returned shows the right timestamp, so I'm thinking it might be a Report Builder issue (?)

Was it helpful?

Solution

And that'd be expected. Starting a job is an asynchronous call so once it's started, control returns back to the caller. You'd then need to start polling the sys job tables to see whether the job is currently executing. You could do that in the same proc call and once the job has hit a terminal state (completed, failed) you could then return your dataset to the user. That would answer your question but goodness, that could get ugly.

Is there no way to perform the ETL prior to people using the report?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top