﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / SQL Agent Job succeeds even though step should fail / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 18:44:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Hi,I have come across same problem last week and found a solution, Dont know this helps or not, because my Proc in the job step, Times out at a step where it has to call a remote proc. Declare @SQL nVarchar,@Remote_ReturnValue int,@ReturnValue intSET @SQL= N'EXEC @Remote_ReturnValue= [' + @LinkedServer + '].[' + @LinkedDatabase + '].[dbo].' + @Table  			EXEC sp_executesql    @Statement= @SQL    ,@params=N'@Remote_ReturnValue INT OUT'    ,@Remote_ReturnValue=@ReturnValue OUT    IF (@ReturnValue &amp;lt;&amp;gt; 0 OR @ReturnValue IS NULL)   BEGIN    RAISERROR(' The linked server timed out!!!!!',16,1)   END  Hope this helpsThis has been tested and going to be released into production</description><pubDate>Thu, 13 Dec 2012 07:26:35 GMT</pubDate><dc:creator>bharadwaj.manchu</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Thanks, Sean. I'll take a look at that code.</description><pubDate>Mon, 03 Dec 2012 08:46:57 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>I am having the same behaviour with SQL Server 2012 RTM.I came up with the following workaround for my environment. This code should go into a job step immediately after the step with the remote server statement and will generate a fail if the previous step suffered a remote query timeout.[code="sql"]DECLARE @JobID UNIQUEIDENTIFIER		,@Message VARCHAR(MAX);SELECT @JobID = $(ESCAPE_NONE(JOBID));WITH CTE AS (	SELECT	ja.message,			ROW_NUMBER() OVER (PARTITION BY j.name ORDER BY ja.run_date DESC, ja.run_time DESC) AS RowNo	FROM	msdb..sysjobs j	JOIN	msdb..sysjobhistory ja		ON j.job_id = ja.job_id	WHERE j.job_id = @JobID)SELECT @message = messageFROM    CTEWHERE	RowNo = 1;IF @message LIKE '%Query timeout expired%'BEGIN	RAISERROR('Timeout', 16, -1);END;[/code]</description><pubDate>Mon, 03 Dec 2012 03:01:03 GMT</pubDate><dc:creator>Sean Pearce</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]rmechaber (7/10/2012)[/b][hr]Brandie, here's a link I found that suggests it is possible to fail a job step with RAISERROR:[url=http://www.bidn.com/blogs/Daniel/ssas/2313/force-a-sql-agent-job-step-to-fail]http://www.bidn.com/blogs/Daniel/ssas/2313/force-a-sql-agent-job-step-to-fail[/url]I just tested this by creating a dummy Agent job with 2 steps.  The first step contained the code from that URL, with [code="sql"]IF 1=1 [/code] to trigger the RAISERROR.  Indeed, the job failed and the error was raised, as shown in the job history.[/quote]How does one work that with a timeout?</description><pubDate>Tue, 10 Jul 2012 08:20:44 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Brandie, here's a link I found that suggests it is possible to fail a job step with RAISERROR:[url=http://www.bidn.com/blogs/Daniel/ssas/2313/force-a-sql-agent-job-step-to-fail]http://www.bidn.com/blogs/Daniel/ssas/2313/force-a-sql-agent-job-step-to-fail[/url]I just tested this by creating a dummy Agent job with 2 steps.  The first step contained the code from that URL, with [code="sql"]IF 1=1 [/code] to trigger the RAISERROR.  Indeed, the job failed and the error was raised, as shown in the job history.HTH,RichP.S.  For this to work, you have to set the job step's Action on Failure to "Quit the Job Reporting Failure"</description><pubDate>Tue, 10 Jul 2012 07:59:36 GMT</pubDate><dc:creator>rmechaber</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>So far as I know, it's not possible to pass an error outside of a jobstep to cause the job itself to fail. The error is only relevant inside the session of the current step. If anyone has tested code they can present, I'd certainly take a look at it. Right now, though, I have given up on this particular issue until it rears its head again. I'm overloaded with projects at the moment and don't have time to test suggestions.When I do get freed up, I will definitely take another look at this thread.</description><pubDate>Tue, 10 Jul 2012 07:30:10 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Would it work to have your job step wrap the execution of the remote SP in some local code; the wrapper would check for a return code indicating successful execution of the SP?  No return code, RAISERROR.Just thinking out loud, haven't tested anything here....Rich</description><pubDate>Mon, 09 Jul 2012 11:49:29 GMT</pubDate><dc:creator>rmechaber</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]mehmet.erbay (7/8/2012)[/b][hr]Hi use "SET ANSI_WARNINGS OFF"in your stored procedure[/quote]Can I ask what makes you think this will work?</description><pubDate>Mon, 09 Jul 2012 04:07:49 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Hi use "SET ANSI_WARNINGS OFF"in your stored procedure</description><pubDate>Sun, 08 Jul 2012 15:14:39 GMT</pubDate><dc:creator>mehmet.erbay</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/22/2012)[/b][hr]Here's the stranger part:  I can't seem to find anyone else who's run into this AND complained about it on the intertubes anywhere.  I'd have figured this would have been sitting in connect somewhere.[/quote]There's plenty of complaints about the original issue on 2k5. Original Issue meaning the job succeeded even though there was a timeout. I don't think anyone managed to figure out what you did.</description><pubDate>Mon, 23 Jan 2012 04:49:04 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]L' Eomot Inversé (1/20/2012)[/b][hr]Drat, that's horrible.  Surely there is some way of detecting this error?[/quote]No, it appears to be a 'feature' of 2k8 for Linked Servers.  I haven't figured out a way to force it to kick one yet.  It reports the timeout, but more like a PRINT message then an error occurred.  Attempting to detecti it would be frightful.Here's the stranger part:  I can't seem to find anyone else who's run into this AND complained about it on the intertubes anywhere.  I'd have figured this would have been sitting in connect somewhere.However, I don't have R2.  My guess is the majority of people running 2k8 are running 2k8 R2 and I can't test that, which would explain the lack of 'hits' on this topic.As a simple test if someone following this has R2, can you please setup the following:Grab yourself two instances of SQL.  2k5+ for one, 2k8 R2 as the other.  Create a database on the 'called' instance and shove a proc in there to call that simply does a wait for 15 seconds.From your 2k8 R2 create a linked server to the first instance.  Set the remote query timeout in the advanced options to 3 (seconds).  Now create a proc that calls the 'waiting' proc on the other server via the linked server.Now call that proc on the 2k8R2 machine.  See if you get a simple message, or an actual error message.Thanks!</description><pubDate>Sun, 22 Jan 2012 00:22:23 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]SQLKnowItAll (1/19/2012)[/b][hr][quote][b]L' Eomot Inversé (1/18/2012)[/b][hr][quote][b]Brandie Tarvin (1/9/2012)[/b][hr]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.[/quote]Try using raiserror with the severity parameter set to 12 or higher in a catch block.  That should cause the step to fail.[/quote]Tom, I think the issue is that there is no error raised.  So a catch block won't ever raise an error.[/quote]Drat, that's horrible.  Surely there is some way of detecting this error?</description><pubDate>Fri, 20 Jan 2012 20:15:44 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]L' Eomot Inversé (1/18/2012)[/b][hr][quote][b]Brandie Tarvin (1/9/2012)[/b][hr]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.[/quote]Try using raiserror with the severity parameter set to 12 or higher in a catch block.  That should cause the step to fail.[/quote]Tom, I think the issue is that there is no error raised.  So a catch block won't ever raise an error.</description><pubDate>Thu, 19 Jan 2012 17:38:29 GMT</pubDate><dc:creator>SQLKnowItAll</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/18/2012)[/b][hr]I did not know that information about the timeout. I'll check into it.Of course, every time I get a moment to work on this issue, another bigger fire comes out of the woodwork. Eventually I'll get this thing working. @=)EDIT: My server values are...[quote]name	minimum	maximum	config_value	run_valueremote login timeout (s)	0	2147483647	20	20[/quote]Am I looking at this correctly? It seems to be set to the maximum # possible, right? "To Infinity and Beyond" and all that jazz?[/quote]Sorry Brandie, I lost track of this thread briefly.  You're correct, that's set to infinity and beyond, basically.I think that's 68 years or so.These are the [strike]three[/strike] two links you'll care about trying to set the timeout, but that won't help the lack of an error being raised:[url]http://msdn.microsoft.com/en-us/library/ms186839.aspx[/url][url]http://msdn.microsoft.com/en-us/library/ms177457.aspx[/url]</description><pubDate>Thu, 19 Jan 2012 16:59:44 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/9/2012)[/b][hr]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.[/quote]Try using raiserror with the severity parameter set to 12 or higher in a catch block.  That should cause the step to fail.</description><pubDate>Wed, 18 Jan 2012 20:10:56 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>I did not know that information about the timeout. I'll check into it.Of course, every time I get a moment to work on this issue, another bigger fire comes out of the woodwork. Eventually I'll get this thing working. @=)EDIT: My server values are...[quote]name	minimum	maximum	config_value	run_valueremote login timeout (s)	0	2147483647	20	20[/quote]Am I looking at this correctly? It seems to be set to the maximum # possible, right? "To Infinity and Beyond" and all that jazz?</description><pubDate>Wed, 18 Jan 2012 12:27:38 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/13/2012)[/b][hr][quote][b]Evil Kraig F (1/12/2012)[/b][hr]This is more a linked server than a job issue.  The proc itself won't error, so the job is clueless there was a problem.[/quote]When you put it that way, it actually makes sense what's going on. Thank you for that translation. [/quote]  My pleasure.  Took me a few rounds of goofing with it to be able to recreate it, then I went down to root level to determine that the proc itself refused to actually error.[quote]My linked server uses the SQL Server Native Client 10.0 provider, is set up using a specific security context (the last option), and has Query Timeout set to 0 (which I thought was no timeout). The other options are listed below.[/quote]A 0 in that window means it uses the defaults in the sp_configure.  It's not an enternal window unless you set your server that way.</description><pubDate>Fri, 13 Jan 2012 14:39:26 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/12/2012)[/b][hr]This is more a linked server than a job issue.  The proc itself won't error, so the job is clueless there was a problem.[/quote]When you put it that way, it actually makes sense what's going on. Thank you for that translation. So, I wonder if this is a linked server "bug" or if it's deliberate behavior with an unintended side effect.My linked server uses the SQL Server Native Client 10.0 provider, is set up using a specific security context (the last option), and has Query Timeout set to 0 (which I thought was no timeout). The other options are listed below.Collation Compatible: FalseData Access: TrueRPC: TrueRPC Out: TrueUse Remote Collation: TrueCollation Name: &amp;lt;blank&amp;gt;Connection Timeout: 0Distributor: FalsePublisher: FalseSubscriber: FalseLazy Schema Validation: FalseEnable Promotion of Distributed Transactions: True</description><pubDate>Fri, 13 Jan 2012 04:49:20 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/12/2012)[/b][hr]Successful completion of a failure, but that's primarily because the proc doesn't actually fail, which is just... wierd.  Try/Catch is also useless, as it's not an actual failure.  Blasted strange.  The workaround will not function.  Hmmmmm.[/quote]That's kind of what I expected to happen, so I'm not surprised.[quote]By chance, are you also connecting from a 2k8 machine running the agent and the local DB with the connection attached to a 2k5 machine like I am?  I've reviewed some errors for this and it appears others have gotten an actual error to occur from this.[/quote]2k8 to 2k8. One is an app server, the other is my db server. SP1.</description><pubDate>Fri, 13 Jan 2012 04:45:01 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Confirmed.  2k8 R1 SP3 does NOT fail the query on query timeout through to a SQL 2k5 server.  I do not currently have two 2k8 instances to play with.  I'm asking one of my DBAs to go and test if this is a source or destination version issue.This is more a linked server than a job issue.  The proc itself won't error, so the job is clueless there was a problem.</description><pubDate>Thu, 12 Jan 2012 16:05:21 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Additional information.  SQL 2k8 R1 SP1 talking to SQL 2k5 does not fail properly.SQL 2k5 talking to 2k8 R1 SP1 DOES fail properly.  I'm going to upgrade to SQL 2k8 SP3 and see if this got cured.</description><pubDate>Thu, 12 Jan 2012 15:03:14 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/12/2012)[/b][hr][quote][b]Evil Kraig F (1/11/2012)[/b][hr]Brandie, do you have any extra information on what type of timeout it is?  Is it a lock timeout, a remote query lockout, a network timeout, a login timeout?[/quote]I think it's a remote query timeout.[/quote]That did it.  I can see what you see now.  I created a secondary linked server and set the connection timeout and query timeouts to 1 and then built a passthrough proc to call the proc on the foreign server.  Said foreign proc was nothing more than a waitfor delay '00:00:15'.Successful completion of a failure, but that's primarily because the proc doesn't actually fail, which is just... wierd.  Try/Catch is also useless, as it's not an actual failure.  Blasted strange.  The workaround will not function.  Hmmmmm.My Google Fu does fail me now.By chance, are you also connecting from a 2k8 machine running the agent and the local DB with the connection attached to a 2k5 machine like I am?  I've reviewed some errors for this and it appears others have gotten an actual error to occur from this.</description><pubDate>Thu, 12 Jan 2012 14:52:51 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/11/2012)[/b][hr]Brandie, do you have any extra information on what type of timeout it is?  Is it a lock timeout, a remote query lockout, a network timeout, a login timeout?[/quote]I think it's a remote query timeout.It ran over the weekend and I didn't notice the problem until two days later because the job didn't fail:OLE DB provider "SQLNCLI10" for linked server "MyServer" returned message "Query timeout expired". [SQLSTATE 01000] Job 'XXXX Report Run' : Step 2, 'Run XXX Proc' : Began Executing 2012-01-02 04:40:02EDIT: I've been fighting other fires, so haven't had a chance to test a deliberate failure of a job. As soon as I put these out, I'm going to go back to testing the job itself.</description><pubDate>Thu, 12 Jan 2012 05:59:47 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>To add to that, it depends on the timeout.  For example, a lock timeout:[img]http://www.sqlservercentral.com/Forums/Attachment10621.aspx[/img]Definately will fail the step (and thus the job).I did this by trying to update the same record via a proc called from the job step as I had in a hanging transaction in another query &amp;#119;indow.</description><pubDate>Wed, 11 Jan 2012 13:40:29 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Brandie, do you have any extra information on what type of timeout it is?  Is it a lock timeout, a remote query lockout, a network timeout, a login timeout?I'm trying to recreate the issue in my sandboxes today out of curiousity and it would help if I knew which exact one to muck with the sandboxes.</description><pubDate>Wed, 11 Jan 2012 13:33:40 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>Brain fart today... Erasing irrelevant comment...</description><pubDate>Wed, 11 Jan 2012 13:11:18 GMT</pubDate><dc:creator>SQLKnowItAll</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>I'll give the suggestion a try and see what happens. Thanks,</description><pubDate>Wed, 11 Jan 2012 04:59:15 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/10/2012)[/b][hr][quote][b]Brandie Tarvin (1/9/2012)[/b][hr][quote][b]Evil Kraig F (1/6/2012)[/b][hr][quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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.[/quote]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.[/quote]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).[/quote]Hm, what about something like this:TRY(Exec MyServer.MyDB.MySchema.MyProc)CATCH(SELECT IDontExist FROM TableNotThere)END[/quote]That's what I used to do when I did more dev work.  I did SELECT * FROM BreakFromSP... Worked like a charm!</description><pubDate>Tue, 10 Jan 2012 14:42:35 GMT</pubDate><dc:creator>SQLKnowItAll</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/9/2012)[/b][hr][quote][b]Evil Kraig F (1/6/2012)[/b][hr][quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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.[/quote]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.[/quote]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).[/quote]Hm, what about something like this:TRY(Exec MyServer.MyDB.MySchema.MyProc)CATCH(SELECT IDontExist FROM TableNotThere)END</description><pubDate>Tue, 10 Jan 2012 14:29:01 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Evil Kraig F (1/6/2012)[/b][hr][quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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.[/quote]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.[/quote]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).[quote][b]jnuqui (1/8/2012)[/b][hr]FYI that SQL server checks your script before you could create the job. :D it should also fail during job creation.[/quote]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.[quote][b]jnuqui (1/8/2012)[/b][hr]you may want to share your script for this. so we could discuss this weird event. :) [/quote]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.</description><pubDate>Mon, 09 Jan 2012 05:26:44 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>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. :) </description><pubDate>Sun, 08 Jan 2012 23:27:11 GMT</pubDate><dc:creator>jnuqui</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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.[/quote]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.</description><pubDate>Fri, 06 Jan 2012 12:44:58 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]MysteryJimbo (1/6/2012)[/b][hr][quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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?[/quote]I may be missing the obvious.  How do you generate a "Query Timeout" in a stored procedure in a SQL Agent Job?[/quote]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.</description><pubDate>Fri, 06 Jan 2012 11:24:39 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]azdzn (1/6/2012)[/b][hr]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.[/quote]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.</description><pubDate>Fri, 06 Jan 2012 11:20:25 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>[quote][b]Brandie Tarvin (1/6/2012)[/b][hr]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?[/quote]I may be missing the obvious.  How do you generate a "Query Timeout" in a stored procedure in a SQL Agent Job?</description><pubDate>Fri, 06 Jan 2012 09:57:14 GMT</pubDate><dc:creator>MysteryJimbo</dc:creator></item><item><title>RE: SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>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.</description><pubDate>Fri, 06 Jan 2012 09:42:09 GMT</pubDate><dc:creator>azdzn</dc:creator></item><item><title>SQL Agent Job succeeds even though step should fail</title><link>http://www.sqlservercentral.com/Forums/Topic1231429-391-1.aspx</link><description>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?</description><pubDate>Fri, 06 Jan 2012 06:45:48 GMT</pubDate><dc:creator>Brandie Tarvin</dc:creator></item></channel></rss>