Logging erroneous queries only on SQL server

I have what would seem like an easy goal to achieve, but I have not found a good solution. Google does not shed light on it, and I just hope that I was looking for a solution in the wrong place, or just trying to use the tools in the wrong way ...

Or maybe today it's too late for me to think what I think :) But on this I hope that you can help me.

I need to be able to log only erroneous queries that were executed on a particular instance of SQL Server. I thought that SQL Profiler would allow me to do this as soon as possible, but I could not find a combination of parameters that would allow me to register only those queries that returned an error (most likely a parsing error) + error information.

Imagine a SQL Server with 100 queries running every second, and only 1 or 2 malformed queries every day, which leads to a parsing error. I just need to be able to come and see these 1-2 requests per day without having to run a very expensive profile for all requests in the system and having to dig it every day.

Is this even possible?

+5
source share
1 answer

Set up tracing for the exception event class , SQL: BatchCompleted Event Class, and RPC: complete event class . Add a filter for Errornot equal to 0. Run the trace. Done.

+10
source

All Articles