I am aware of:
SELECT @@ERROR
but it will give me only an ERROR CODE (a number) and I need a full text message like:
Cannot insert duplicate key row in object 'dbo.TABLE_NAME' with unique index 'IX_ID_unique'.
The statement has been terminate开发者_Go百科d.
How can I do that in MS Sql Server 2005 ?
EDIT: I need to acquire this error message on Linux and Windows platforms.
What about ERROR_MESSAGE
?
See also : Retrieving Error Information in Transact-SQL
And, from PHP (as your question is tagged php
), take a look at :
mssql_get_last_message
PDO::errorInfo
Depending on the API you're using to access your MS SQL Server database, of course.
With the sqlsrv extension module you can use sqlsrv_errors( [int $errorsAndOrWarnings] ).
精彩评论