Point 1:- RAISERROR is used to raise error / warning back to the application or a catch block.
Point 2:- Syntax of RAISERROR is as below
RAISERROR (@Messageid -- Error message number stored in Sys.messages table
@ErrorSeverity, -- Severity ( 0-25)
@ErrorState -- State
@ErrorMessage, -- Error message string
);
Point 3:- You can raise system error message or user defined error message. For user defined error messages it should be greater than 50000.
Point 4:- If you do not specify the error number the error message id is considered 50000 (user defined error message)
Point 5:- Error severity defines how serious the error is. Severity levels from 0 through 18 can be specified by any user. Severity levels from 19 through 25 can only be specified by members of the sysadmin.
Point 6:- If error is raised from multiple location you can use this number to define from which location the error is raised.
You can buy our SQL Server interview questions book from flipkart by clicking here
Watch this awesome video of SQL Server interview question:- What are Sub Query and Co-related Queries?
See our 500 video of .NET and SQL server interview question
Regards,
Click to view more from author's on SQL Server Interview question