I have a task scheduled using an SQL Server agent that runs sproc, which runs some other sprocs. Each sproc looks like this:
BEGIN TRY -- do stuff END TRY BEGIN CATCH DECLARE @errorMessage varchar(4000) DECLARE @procName varchar(255) SELECT @errorMessage = error_message() SELECT @procName = OBJECT_NAME(@@PROCID) RAISERROR('%s threw an exception: %s', 16, 1, @procName, @errorMessage) END CATCH
All this works great - errors go up and stack, life is good. However, my RAISERROR calls do not crash the job β I am set to receive a notification when the job doesnβt work, but never receive it. Email notifications work because I receive emails if I change the notification to "when the job is successful." Is there any other function that I should use here instead of RAISERROR?
icurious
source share