In .NET and standard TSQL it is good practise to embed your code in TRY..CATACH constructs; if an execution error occurs, in certain circumstances, depending on severity level, the error can be dealt with:
severity level 0 - 10: informational error - control switches doesn't to catch block
severity level 11 - 16: error can be corrected by user - control switches to catch block
severity level 17 - 19: software error - for administrator
severity level 20 - 25: fatal error - db connection ends
Error Message Severity Levels
The severity level of an error message provides an indication of the type of problem that Microsoft® SQL Server™ 2000 has encountered.
Severity level 10 messages are informational and indicate problems caused by mistakes in the information you have entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user.
Severity levels from 17 through 25 indicate software or hardware errors. You should inform the system administrator whenever problems that generate errors with severity levels 17 and higher occur. The system administrator must resolve these errors and track their frequency. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
The system administrator should monitor all problems that generate severity levels from 17 through 25 and print the error log that contains information to backtrack from the error.
If the problem affects an entire database, you can use DBCC CHECKDB (database ) to determine the extent of the damage. DBCC may identify some objects that must be removed and will optionally repair the damage. If damage is extensive, the database might have to be restored.
When specifying user-defined error messages with RAISERROR, use error message numbers greater than 50,000 and severity levels from 0 through 18. Only system administrators can issue RAISERROR with a severity level from 19 through 25.
http://msdn.microsoft.com/en-us/library/aa937483(SQL.80).aspx
No comments:
Post a Comment