I have learned to use the SCOPE_IDENTITY() instead of just @@IDENTITYto get the last identity value inserted in a given scope, which can be quite useful in high-concurrency scenarios. Is there any equivalent to that function for the @@ERROR variable? I mean, is there any way to make sure that whenever I write
IF (@@ERROR <> 0) RETURN
I am in fact forcing the function to return because of the very last command in this scope caused an error?
From Books Online:
@@ERROR only returns error information immediately after the Transact-SQL statement that generates the error.
@@Error is only within the current scope. So it should have the value for whatever sent the proc to the catch block no matter which of several statements was the one that errored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With