tags:

views:

165

answers:

2

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 terminated.

How can I do that in MS Sql Server 2005 ?

EDIT: I need to acquire this error message on Linux and Windows platforms.

+1  A: 

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 :

Depending on the API you're using to access your MS SQL Server database, of course.

Pascal MARTIN
ERROR_MESSAGE() requries sql:TRY..CATCH blocks and php:mssql_get_last_message() returns only the last line of an error, so in above example I get only "The statement has been terminated." (which is much less important information then that the first part about duplicate key).
JohnM2
A: 

With the sqlsrv extension module you can use sqlsrv_errors( [int $errorsAndOrWarnings] ).

VolkerK
Thanks, but the solution must work on Windows and Linux platform. I will include that information in my question.
JohnM2
Is patching the mssql module an option?
VolkerK
Yes, how and what would I path?
JohnM2