@@ERROR function returns the most recent error code. 0 means no error.
Error level is break down to these categories:
1 - 10: warning
11- 16: errors can be corrected by user
17 - 19: more serious exceptions, such as out of memory.
20 -25: fatal connection and server level exceptions.
Who followed that? Even MS does not. So information purpose.
RAISERROR without specifying message id uses 50000 as its message id.
Error level can be overridden by specifying new number other than -1. -1 one means to use error level defined in sys.messages.
When creating custom messages, message number ranges 50000 to 2147483647. The message is added by sp_addMessage procedure. Message text and severity can be updated by also using same procedure with @replace='Replace'. sp_alterMessage can be used to change other parts of message. sp_dropMessage to drop user defined message. Apparently, the first two procedures are not well designed, bear with them and remember them.
Error can be logged to SQL Server's error log by using WITH LOG if invoked by sysadmin or user having ALTER TRACE permission.
No comments:
Post a Comment