I would like a way to record any time there is a user error and the SQL that generated that error. Using profiler I don't see a way to programatically correlate the exception message, the user error message, and the SQL:BatchStarting/SP:Starting text data fields.
I hate seeing errors like 'Invalid length parameter passed to the RIGHT function.' and not being able to quickly see the actual code or SP that caused the error.
Obviously the SPID is linked between these, but the SPID is only linked for that split second between execution and error, and then that SPID is re-used for a different process. Could I somehow trigger on the exception and grab DBCC input buffer?
Any thoughts?