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 2000 Forums
 SQL Server Administration (2000)
 Forcing a Job step to fail with T-sql

Author  Topic 

tswern
Starting Member

10 Posts

Posted - 2003-11-09 : 04:51:20
Is there a way to force a jobs step to fail using T-SQL?
Say for example if a select from a table does not returns any rows, is it possible for me to return a something to make SQL 2000 log the step as failure?

thanks in advance!

Save the dugongs!

nr
SQLTeam MVY

12543 Posts

Posted - 2003-11-09 : 05:19:45
Try a raiserror.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-11-09 : 05:47:52
... or try something like this:

insert into t select * from tt where n>555
if @@rowcount=0 delete from NonExistingTable_Name

And this step will be marked as failed...
Go to Top of Page
   

- Advertisement -