adimit
asked on
Retrieving Error DEscription of an error in a stored procedure or other sql script
This question is about error trapping without using try/catch.
I can goto an errorhandler when @@error > 0. What I don't know how to do is to retrieve the
error details, such as description, source etc.. when an error is generated. How do I do this?
I can goto an errorhandler when @@error > 0. What I don't know how to do is to retrieve the
error details, such as description, source etc.. when an error is generated. How do I do this?
ASKER
the goal as specified in my question is not to use try/catch.
Some of them you can find on sysmessages table
select * from master..sysmessages
select * from master..sysmessages
ASKER
the sysmessages table does not provide a mechanism to determine which error is the one that I want. I only know the error number as a filter, and the sysmessages table does not provide a timedate stamp. Any other mechanisms?
The try/catch statements have too many limitations
The try/catch statements have too many limitations
I dont think there is any other options ?
>The try/catch statements have too many limitations
Can u tell us what u r facing wrong with try..catch
>The try/catch statements have too many limitations
Can u tell us what u r facing wrong with try..catch
ASKER
at this point it seems that there is no way to do what I am asking for. I don't wan't to be difficult but the try/catch statement cannot be used in this case. For one reason, I can't put in to stored procedures that are interacting with another piece of software that I have. Even if this were not the case the following excerpt from the sql server help should be enough:
A TRY&CATCH construct cannot span multiple batches. A TRY&CATCH construct cannot span multiple blocks of Transact-SQL statements. For example, a TRY&CATCH construct cannot span two BEGIN&END blocks of Transact-SQL statements and cannot span an IF&ELSE construct.
at
Please let me know once again if there is something outside of the try/catch statement that I can use.
A TRY&CATCH construct cannot span multiple batches. A TRY&CATCH construct cannot span multiple blocks of Transact-SQL statements. For example, a TRY&CATCH construct cannot span two BEGIN&END blocks of Transact-SQL statements and cannot span an IF&ELSE construct.
at
Please let me know once again if there is something outside of the try/catch statement that I can use.
ASKER
As an alternative, how can I send the error message and some custom text to the sql log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://sequelserver.blogspot.com/2007/07/exception-handling-using-trycatch.html