timscronin
MIS
If I have stored proc A which sends a value to be processed by stored proc B, but stored proc b errors out. If I have stored proc B return on error, is the @@error available for Stored proc A, or is the scope limited to B?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
EXEC sp_smonething
IF @@ERROR <> 0
-- error happened
EXEC sp_smonething
DECLARE @i int
IF @@ERROR <> 0
-- that line never be ocuured
Remarks
When Microsoft® SQL Server™ completes the execution of a Transact-SQL statement, @@ERROR is set to 0 if the statement executed successfully. If an error occurs, an error message is returned. @@ERROR returns the number of the error message until another Transact-SQL statement is executed. You can view the text associated with an @@ERROR error number in the sysmessages system table.
Because @@ERROR is cleared and reset on each statement executed, check it immediately following the statement validated, or save it to a local variable that can be checked later.