I am trying to get my code to exit a trigger after an error is thrown with 'raiserror' inside of a try-catch. The code in the catch is always executed. I try putting a 'return' after the 'raiserror', but that doesn't help. I am calling an SP
which performs an update on a table with an update trigger.
CREATE TRIGGER [dbo].[i_update_CheckJobConstraints] ON [dbo].[Job]
INSTEAD OF UPDATE
declare @Manager varchar(64); -- I pass 'A' in here to force the error
Set @Manager = (Select top 1 Manager from inserted);
--The value 'A' is not in the [Person] table
IF @Manager not in (Select distinct (Person) from Person where isStaffManager = 1)
RAISERROR 22002 'Manager Required or not Authorized';
-- I want the trigger to exit here returning error 22002, but the code jumps to the catch block and returns error 2203.
RAISERROR 22003 'Invalid Exception Title';
View Complete Post