开发者

How to get last full MS SQL Server error message?

开发者 https://www.devze.com 2022-12-28 16:55 出处:网络
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:

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] ).

0

精彩评论

暂无评论...
验证码 换一张
取 消