I have a database Microsoft SQL Server 2008r2 I have some applications in different programming languages. Some of them are legacy and I would not like to modify. Is there a way to log at server level all query errors, regardless of the application causing it? I would like to know, for each error, the query causing it, the error type, and ideally loginame and hostname.
If you are just looking to log this information, you can set up an Extended Events session and capture the
To test this out, here is a test error with
Then by looking at the XE log through the sys.fn_xe_file_target_read_file system function, you will be able to see all of the logged errors.
Yes. Monitor for Event Notifications in the Errors and Warnings Event Category. Specifically, the Exception event will be raised for each error. For example, based on the code in MS SQL Server third party transaction blocking monitor tools:
If we check the queue, we'll see all exception reported: