Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can I schedule a report to run via SQL Job Agent?


Can I schedule a report to run via SQL Job Agent?

Author
Message
jbalbo
jbalbo
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 668
Hi

I was wondering if I can schedule a report to be emailed via the job agent?

I know I can Schedule it via SSRS
but here is what I need...
I run this report which runs via a SP which updates a field to say "Processed"
When the job is run and sent, I want to run another SP that changes the "Processed" to "Completed"
But I don't want to run it in case the first part fails for some reason...

Thanks
Joe
Ed Zann
Ed Zann
Mr or Mrs. 500
Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)

Group: General Forum Members
Points: 507 Visits: 1391
See this link
http://sqlserverbiblog.wordpress.com/tag/manually-starting-subscription/



jbalbo
jbalbo
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 668
Hi Ed,

Thanks for getting back..
so I followed the blog and it worked fine

USE msdb
EXEC sp_start_job @job_name = 'C387D481-5A3D-4DF8-89BC-10A55A5FE1F4'

But....

I wanted to run a second step which EXEC an sp which updates a flag in the step1 sp for the report

The problem is when I add the second step the report is blank, because the second step has updated the flag..

Is there a way to email the report before the update in step2 or maybe run as two jobs?

Thanks
Joe
Ed Zann
Ed Zann
Mr or Mrs. 500
Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)Mr or Mrs. 500 (507 reputation)

Group: General Forum Members
Points: 507 Visits: 1391
I'm not sure I totally understand your situation - but a couple of approaches come to mind:

1) Use the report query to do the update. So you would take the original Processed data set and stuff it into a temp table; then issue an update for the Completed flag; then select your data set for the report back from the temp table. I think this can be done. It's like you're issuing a series of SQL statements as you would in a strored proc.

2) Use the SSRS subscription to output the report to, say, a PDF instead of email. Then use Database mail to send the PDF as an attachment. Then update your Completed flag.



jbalbo
jbalbo
SSC-Addicted
SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)SSC-Addicted (405 reputation)

Group: General Forum Members
Points: 405 Visits: 668
Hi Ed..

Thanks,
Actually I did sort of do the first one...

first part of the query updates the flags marked 'Processed' to 'Completed'
second part updates "null" to "Processed"
then data is written to report selecting processed records...

Since the report is scheduled daily
the following day it will mark those records 'Processed' to 'Completed'
if for some reason it fails the records will be marked "Processed" still sending then to the report

That was my whole thing for step2 to mark them as processed...
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