How to get SQL statement that caused database error
I wonder if there is any suitable approach (in the sense of robustness/resource efficiency/etc.) to retrieve SQL statement that raised database error during stored procedure execution. Surely, there are some helpful items we could get from the Condition Area of the Diagnostics Area when condition handling is being processed. But what about the statement that caused those conditions? Perhaps we could found it out in some attribute of Statement Area? Or something.. No doubt, a simple and elegant solution to this problem must exist. Please, help me find it out!