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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-03-30 : 08:39:05
|
| raj writes "Using SQL Server 2000I run 20 stored procedures as steps in a job scheduled to run each day through the SQL Server Agent.A source table (dbo.Application)is required to be rebuilt each day and it is important current data exists for jobs to be successful.Therefore the first step isCREATE PROCEDURE [sproc_Verify] ASDECLARE @Error INTSET @Error = 0IF EXISTS(SELECT * FROM dbo.APPLICATION)OR (SELECT MAX(CommencedDate)AS d FROM dbo.APPLICATION) < GETDATE() - 1BEGIN SET @Error =1ENDRETURN( @Error)GOWhat I want to happen if the RETURN = 1 is for the entire job to fail and send me an email.The job is succeeding wheather or not the RETURN is 0 or 1.Cant seem to find an answer anywhere.I would be greatfull for any assistance." |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-03-30 : 11:48:46
|
| In your job window, you need to do something like this:DECLARE @retvalue INTEXEC @retvalue = sproc_VerifyIF @retvalue = 1 BEGIN RAISERROR('Error on step1',16,1) ENDMake sure you have the job setup to fail on error.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|