When does RAISERROR fire in a stored procedure?
I've got a stored procedure that contains a try-catch block. In the catch
block I call raiserror() to rethrow the error with some context.
I was expecting that if an error occurred the raiserror() would be called
and execution would immediately return from the stored procedure to the
calling code. However, this doesn't appear to be the case. It looks like
execution of the stored procedure continues until it hits a return
statement, then the raiserror() takes effect.
Is this correct - that raiserror() won't have an effect until return is
called or the end of the stored procedure is reached?
I'm using SQL Server 2012.
No comments:
Post a Comment