How to find the sqlstate of a query | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to find the sqlstate of a query

Hi all, I hope everyone knows that there is something called a sqlstate(like sqlcode) for each sql query which i hope is generic across he databases. I am not clear about that. Can anyone explain me the concept of sqlstate and provide me a list of sqlstates.Please treat this query as urgent. Arun Kumar,
BAngalore
In SQL Server, SQlState related to an error and is an arbitrary integer from 1 through 127 that represents information about the invocation state of the error. Roji. P. Thomas
SQL Server MVP
http://toponewithties.blogspot.com

..to add Roji’s note:
quote:
The SQLSTATE is a five-character error code defined originally in the ODBC specification. SQLSTATE codes are common across all ODBC drivers and provide a way for applications to code basic error handling without testing for all of the different error codes returned by various databases. The ODBC SQLSTATE has nothing to do with the state attribute of Database Engine error messages. ADO uses an errors object and errors collection to return standard error information such as SQLSTATE, native error number, and the error message string. These are the same as their ODBC counterparts. ADO does not support any provider-specific error interfaces; Database Engine-specific error information, such as the severity or state, is not available to ADO applications. OLE DB uses the IErrorInfo interface to return standard error information, such as the SQLSTATE, native error number, and error string. These are the same as their ODBC counterparts. The OLE DB Provider for SQL Server defines an ISQLServerErrorInfo interface to return Database Engine-specific information, such as the severity, state, procedure name, and line number.

Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.
I gues it has the same meaning in other DB products also. http://publib.boulder.ibm.com/infoc…?topic=/com.ibm.db2.udb.doc/core/r0sttmsg.htm
Roji. P. Thomas
SQL Server MVP
http://toponewithties.blogspot.com

]]>