Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 T-sql to force Fail a step

Author  Topic 

rkuhnjr
Starting Member

2 Posts

Posted - 2008-11-04 : 15:21:25
I created a job with about 5 steps that process data and uses ftp to send data to our customer.

However they want to be able to shut off the job which runs nightly sometimes.

I'm going to build a table to house date ranges that will allow our suctomer to input date ranges using a UI that will cause the job to not process.

So my question is after I do a select with GetDate() between such AND such
How can i set it to cause a job step to fail if @@rowcount > 1

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-04 : 15:24:51
Just raise an error via RAISERROR.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-11-04 : 15:29:46
Look at RAISEERROR

http://msdn.microsoft.com/en-us/library/ms178592(SQL.90).aspx
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-04 : 15:36:13
[code]IF @@ROWCOUNT > 1
BEGIN
RAISERROR('This is the error message.', 16, 1)
RETURN -100
END[/code]


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

rkuhnjr
Starting Member

2 Posts

Posted - 2008-11-04 : 15:39:45
Thanks!
I tried using Raiseerror but had the severity set at 0 so it was still reporting success
Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-04 : 15:58:05
Only severities 11 and above is reported as error.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -