June 23, 2010 at 1:07 pm
Hi,
I want to create a step in an agent job to check the rows in a table. If rowcount = 0 then quit job, else proceed to next step. I'm not sure how to write this, so any help/cod samples would be much appreciated!
Thanks!
Code
June 23, 2010 at 1:21 pm
You may call sp_stop_job in step to stop job, and you can check job history from log or directly from job history table to identify which time the job was terminated.
No Signature
June 23, 2010 at 1:46 pm
Thanks for the reply. I’m having trouble coming up with the correct syntax for your solution, can you help? This is the direction I was going, but I could be way off track..
SELECT CASE WHEN (select count(BILLIDNO) FROM WORK_JTR.[dbo].[TESTMAIL]) >0 THEN '?' - –What do I put here to advance to the next step?
ELSE EXEC dbo.sp_stop_job
N'JOST TEST MAIL'
END
June 23, 2010 at 2:52 pm
Code-1029433 (6/23/2010)
Thanks for the reply. I’m having trouble coming up with the correct syntax for your solution, can you help? This is the direction I was going, but I could be way off track..SELECT CASE WHEN (select count(BILLIDNO) FROM WORK_JTR.[dbo].[TESTMAIL]) >0 THEN '?' - –What do I put here to advance to the next step?
ELSE EXEC dbo.sp_stop_job
N'JOST TEST MAIL'
END
IF (select count(BILLIDNO) FROM WORK_JTR.[dbo].[TESTMAIL])=0
EXEC msdb.dbo.sp_stop_job
actually, it doesn't matter what you put there as long as it has correct sytax, such as "PRINT ' ' "
No Signature
June 23, 2010 at 3:44 pm
Excellent, thanks!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply