April 1, 2020 at 3:40 pm
I am using SQL Server 2005 and I need to force a job to fail based on a condition of an IF statement. This is an overview what my code is doing:
IF (SELECT '1') = 1
BEGIN
PRINT 'Yes'
END
ELSE
BEGIN
PRINT 'No'
END
The above isn't my exact code but this gives a very short overview what my code is achieving at present.
Basically where it says PRINT 'No' I want it to fail the job instead so it can send an email notification out based on that failure.
Is that possible to accomplish?
Thanks in advance.
April 1, 2020 at 6:14 pm
You should be able to use RAISERROR with a severity of, say, 16. Please see the following for more info on RAISERROR.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy