|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:57 AM
Points: 6,724,
Visits: 5,796
|
|
Does anyone know why a Transact-SQL job step that executes a stored procedure and returns a "Query timeout" response continues on as if the job step succeeded?
Is there anyway to prevent this behavior?
Brandie Tarvin, MCITP Database Administrator, MCDBA, MCSA
Webpage: http://www.BrandieTarvin.net LiveJournal Blog: http://brandietarvin.livejournal.com/ On LinkedIn!, Google+, and Twitter.
Freelance Writer: Shadowrun Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 2:10 PM
Points: 1,493,
Visits: 240
|
|
The step must have "Go to the next step" as "On failure Action". See advanced tab in Job STep properties to set up this option.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 2:25 AM
Points: 1,125,
Visits: 14,518
|
|
Brandie Tarvin (1/6/2012) Does anyone know why a Transact-SQL job step that executes a stored procedure and returns a "Query timeout" response continues on as if the job step succeeded?
Is there anyway to prevent this behavior?
I may be missing the obvious. How do you generate a "Query Timeout" in a stored procedure in a SQL Agent Job?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:57 AM
Points: 6,724,
Visits: 5,796
|
|
azdzn (1/6/2012) The step must have "Go to the next step" as "On failure Action". See advanced tab in Job STep properties to set up this option.
There's no must about it. You misunderstand what I'm saying. I'm not talking about the Advanced Actions.
The job step itself ends with success. It does not fail. It should fail, but it is not failing.
Brandie Tarvin, MCITP Database Administrator, MCDBA, MCSA
Webpage: http://www.BrandieTarvin.net LiveJournal Blog: http://brandietarvin.livejournal.com/ On LinkedIn!, Google+, and Twitter.
Freelance Writer: Shadowrun Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:57 AM
Points: 6,724,
Visits: 5,796
|
|
MysteryJimbo (1/6/2012)
Brandie Tarvin (1/6/2012) Does anyone know why a Transact-SQL job step that executes a stored procedure and returns a "Query timeout" response continues on as if the job step succeeded?
Is there anyway to prevent this behavior?I may be missing the obvious. How do you generate a "Query Timeout" in a stored procedure in a SQL Agent Job?
It's not that hard. It's easier, in fact, to get a Query Timeout in a job step than it is in SSMS. In this instance, the proc has a very heavy query load and is doing lots of calcs. This particular proc is also retrieving information across a Linked Server.
To be clear: I'm not concerned with fixing the timeout issue itself. I've got that covered. What I'm concerned with is how to force a SQL Agent job step to fail if it runs into a timeout issue.
Brandie Tarvin, MCITP Database Administrator, MCDBA, MCSA
Webpage: http://www.BrandieTarvin.net LiveJournal Blog: http://brandietarvin.livejournal.com/ On LinkedIn!, Google+, and Twitter.
Freelance Writer: Shadowrun Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 5:35 PM
Points: 5,722,
Visits: 6,194
|
|
Brandie Tarvin (1/6/2012)
To be clear: I'm not concerned with fixing the timeout issue itself. I've got that covered. What I'm concerned with is how to force a SQL Agent job step to fail if it runs into a timeout issue.
I believe you'll have to wrap the call with a TRY/CATCH and do a custom RAISEERROR if it occurs, but I don't have the ability to modify my network to create a mini-lab to confirm I can see the same functionality and that it'll cure it.
- Craig Farrell
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions | Forum Netiquette For index/tuning help, follow these directions. |Tally Tables Twitter: @AnyWayDBA
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Yesterday @ 6:02 AM
Points: 48,
Visits: 166
|
|
your job is a success because you've successfully executed a script which should fail. lol. kiddin.
FYI that SQL server checks your script before you could create the job. :D it should also fail during job creation.
you may want to share your script for this. so we could discuss this weird event. :)
===============================================================
"lets do amazing" our company motto..
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 9:57 AM
Points: 6,724,
Visits: 5,796
|
|
Evil Kraig F (1/6/2012)
Brandie Tarvin (1/6/2012)
To be clear: I'm not concerned with fixing the timeout issue itself. I've got that covered. What I'm concerned with is how to force a SQL Agent job step to fail if it runs into a timeout issue.
I believe you'll have to wrap the call with a TRY/CATCH and do a custom RAISEERROR if it occurs, but I don't have the ability to modify my network to create a mini-lab to confirm I can see the same functionality and that it'll cure it.
Craig, I get what you're saying, but I can't figure out how to pass the error outside of the code context to fail the job step itself. Raising an error is, in and of itself, a successful prosecution of the code. And I see no options within the job step window that allow me to set success or failure of that job step.
The only option I'm seeing is having that error attempt to update the sysjobsteps table, but I hate the idea of updating sys tables (if I could even do that anymore).
jnuqui (1/8/2012) FYI that SQL server checks your script before you could create the job. :D it should also fail during job creation.
SQL Server only checks for syntax errors and object existence during job creation. There's no reason why job creation would fail in this instance.
jnuqui (1/8/2012)
you may want to share your script for this. so we could discuss this weird event. :)
Exec MyServer.MyDB.MySchema.MyProc;
That's all it is, one simple line of code in a Transact-SQL job step. And I'm not the only person who has this issue. When I googled the problem, I found articles referencing SQL 2005 too with similar comments (the job step succeeded when the query timed out). Unfortunately, none of those articles had a solution to my problem.
Brandie Tarvin, MCITP Database Administrator, MCDBA, MCSA
Webpage: http://www.BrandieTarvin.net LiveJournal Blog: http://brandietarvin.livejournal.com/ On LinkedIn!, Google+, and Twitter.
Freelance Writer: Shadowrun Latchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 5:35 PM
Points: 5,722,
Visits: 6,194
|
|
Brandie Tarvin (1/9/2012)
Evil Kraig F (1/6/2012)
Brandie Tarvin (1/6/2012)
To be clear: I'm not concerned with fixing the timeout issue itself. I've got that covered. What I'm concerned with is how to force a SQL Agent job step to fail if it runs into a timeout issue.
I believe you'll have to wrap the call with a TRY/CATCH and do a custom RAISEERROR if it occurs, but I don't have the ability to modify my network to create a mini-lab to confirm I can see the same functionality and that it'll cure it. Craig, I get what you're saying, but I can't figure out how to pass the error outside of the code context to fail the job step itself. Raising an error is, in and of itself, a successful prosecution of the code. And I see no options within the job step window that allow me to set success or failure of that job step. The only option I'm seeing is having that error attempt to update the sysjobsteps table, but I hate the idea of updating sys tables (if I could even do that anymore).
Hm, what about something like this:
TRY (Exec MyServer.MyDB.MySchema.MyProc) CATCH (SELECT IDontExist FROM TableNotThere) END
- Craig Farrell
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions | Forum Netiquette For index/tuning help, follow these directions. |Tally Tables Twitter: @AnyWayDBA
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 9:05 PM
Points: 2,624,
Visits: 3,145
|
|
Evil Kraig F (1/10/2012)
Brandie Tarvin (1/9/2012)
Evil Kraig F (1/6/2012)
Brandie Tarvin (1/6/2012)
To be clear: I'm not concerned with fixing the timeout issue itself. I've got that covered. What I'm concerned with is how to force a SQL Agent job step to fail if it runs into a timeout issue.
I believe you'll have to wrap the call with a TRY/CATCH and do a custom RAISEERROR if it occurs, but I don't have the ability to modify my network to create a mini-lab to confirm I can see the same functionality and that it'll cure it. Craig, I get what you're saying, but I can't figure out how to pass the error outside of the code context to fail the job step itself. Raising an error is, in and of itself, a successful prosecution of the code. And I see no options within the job step window that allow me to set success or failure of that job step. The only option I'm seeing is having that error attempt to update the sysjobsteps table, but I hate the idea of updating sys tables (if I could even do that anymore). Hm, what about something like this: TRY (Exec MyServer.MyDB.MySchema.MyProc) CATCH (SELECT IDontExist FROM TableNotThere) END
That's what I used to do when I did more dev work. I did SELECT * FROM BreakFromSP... Worked like a charm!
Thanks,
Jared SQL Know-It-All
How to post data/code on a forum to get the best help - Jeff Moden
|
|
|
|