The following code can be the simple solution for error handling problems in the SQL Server:
Declare @ErrorCode int
Select @ErrorCode = @@Error
If @ErrorCode = 0
Begin
--Some statement
Update
Select @ErrorCode = @@Error
End
If @ErrorCode = 0
Begin
--Another statement
Insert
Select @ErrorCode = @@Error
End
If @ErrorCode = 0
Begin
--Another statement
Update
Select @ErrorCode = @@Error
End
Return @ErrorCode
More information:
http://msdn2.microsoft.com/en-us/library/aa175920(SQL.80).aspx
Declare @ErrorCode int
Select @ErrorCode = @@Error
If @ErrorCode = 0
Begin
--Some statement
Update
Select @ErrorCode = @@Error
End
If @ErrorCode = 0
Begin
--Another statement
Insert
Select @ErrorCode = @@Error
End
If @ErrorCode = 0
Begin
--Another statement
Update
Select @ErrorCode = @@Error
End
Return @ErrorCode
More information:
http://msdn2.microsoft.com/en-us/library/aa175920(SQL.80).aspx
Comments