SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to Send SSRS Reports(subscriptions) from SQL AGENT JOB STEP


How to Send SSRS Reports(subscriptions) from SQL AGENT JOB STEP

Author
Message
tinnusqlserver
tinnusqlserver
SSC-Enthusiastic
SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)SSC-Enthusiastic (193 reputation)

Group: General Forum Members
Points: 193 Visits: 230
Hi All,

I have a sql agent job "LoadfromOracle" which loads data from oracle to sql server tables(Orders table, Marketing table ) everyday. This job runs everyday at 7:00 am (Avg Execution time is 1 hour), so completes at 8:00 am.

I have a report named "daily report" which uses Orders table, Marketing table to fetch the required data. we had created subscription for this report ("daily report") and this report is send to executives everyday as an email attachment at 8:20 am.

Problem : some times the sql agent job "LoadfromOracle" is taking more time(4-5) hours to complete data load into Orders table, Marketing table. So, without complete data into Orders table, Marketing table the report ("daily report") is using incomplete data and email is sent to executives with wrong/incomplete data at 8:20 am.

My question : Can I include this report subscription(process of sending report as email) as a SQL AGENT JOB STEP in sql agent job "LoadfromOracle". ???? so that in sql agent job "LoadfromOracle" i have

step1: loading data from oracle to sql server

step2: sending report to subscribers as an email attachment

For step1 i will include OnFailureAction = "Quit the job reporting failure".

By doing this i can be sure that unless the data load is completed, the report won't be sent to executives. and if step1 fails then step2(sending report) step will not be executed.

Can any one give me advice on implementing this??

Thanks for your time!!

Raj Vardhan
anthony.green
anthony.green
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24962 Visits: 6519
as you already have the subscription setup, I would remove the schedule from the T-SQL job which is used to run the subscription, then as step 2 of your load from oracle, issue a SP_START_JOB procedure call to run the subscription job.

the script below should help you find the right GUID job name for the report.


SELECT
U.UserName AS SubscriptionOwner,
C.Path AS ReportPath,
CONVERT(XML,S.ExtensionSettings) AS SubscriptionSettings,
S.EventType AS SubscriptionType,
CONVERT(XML,S.Parameters) AS ReportParameters,
S.DeliveryExtension AS DeliveryMethod,
Sc.Name AS ScheduleName,
Rs.ScheduleID
FROM
Subscriptions S
INNER JOIN
Users U
ON
S.OwnerID = U.UserID
INNER JOIN
Catalog C
ON
S.Report_OID = C.ItemID
INNER JOIN
ReportSchedule RS
ON
S.SubscriptionID = RS.SubscriptionID
INNER JOIN
Schedule Sc
ON
RS.ScheduleID = Sc.ScheduleID
ORDER BY
1,2





Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Bob Griffin
Bob Griffin
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2027 Visits: 702
http://www.bidn.com/blogs/kylewalker/ssis/1915/how-to-match-your-subcription-names-with-its-job-id

Some things I've learned researching this topic in sql 2008 r2.

1) ssrs scheduled tasks create a corresponding sqlagent job with a nasty guid name that is meaningless
2) the bidn link above by Mr. Kyle Walker shows the query to retrieve and map the sqlagent guid name to your scheduled ssrs report.
3) putting all this information together with the msdb.dbo.sp_start_job, you can manage your scheduled reports within sql agent jobs with much flexibility.

I'm not sure I'm going to like managing this set up though during deployment of a new ssrs report? We'll see.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search