I am trying to capture a list of all SQL Server errors so my calling C# (.NET 4.0) can do different things based on what occurs.
I am trying to get all of the things in http://technet.microsoft.com/en-us/library/cc645611.aspx and all of the other related pages.
Obviously SQL Server has these in a table somewhere already, but where?
Thanks.
There are two types of errors in SQL Server: system errors and custom errors. System errors can be viewed in the sys. messages system view and are defined by SQL server. Therefore, when a system error occurs, SQL Server will log a system error and may take actions to fix the error.
All system and user-defined error messages in an instance of the Database Engine are contained in the sys. messages catalog view. You can use the RAISERROR statement to return user-defined errors to an application.
SELECT message_id, severity, text
FROM sys.messages
WHERE language_id = 1033; -- assuming US English
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With