Thursday, December 05, 2013

SQL Server RAISERROR

RAISERROR('SQL Does not like the data',16,1)  Break down of the RAISERROR

For the most part, the same exception ranges apply: exception levels between 1 and 10 result in a warning, levels between 11 and 18 are considered normal user errors, and those above 18 are considered serious and can only be raised by members of the sysadmin fixed server role. User exceptions raised over level 20, just like those raised by SQL Server, cause the connection to break.

The state argument can be any value between 1 and 127, and has no effect on the behavior of the exception. It can be used to add additional coded information to be carried by the exception—but it’s probably just as easy to add that data to the error message itself in most cases. I generally use a value of 1 for state when raising custom exceptions.

Reference - http://dataeducation.com/blog/sql-servers-raiserror-function
Post a Comment