Error Handling: @error

After an INSERT, UPDATE, or DELETE, check the value of @error (copied from @@error). On success, the value would be 0.

See Standardized RAISERROR Calls for more information and example code.