仅在 SQL Server 上记录错误查询
我有一个看似很容易实现的目标,但我还没有找到一个好的解决方案。谷歌没有透露这一点,我只是希望我一直在错误的地方寻找解决方案,或者只是试图以错误的方式使用工具......
或者也许今天对我来说已经太晚了,无法清楚地思考: )但我希望这是你能帮助我的地方。
我需要能够仅记录在 SQL Server 的特定实例上执行的错误查询。我认为 SQL Profiler 可以让我立即完成此操作,但我无法找到允许我仅记录那些返回错误(很可能是解析错误)+错误详细信息的查询的设置组合。
想象一下 SQL Server 每秒执行 100 个查询,每天只有 1 或 2 个格式不正确的查询导致解析错误。我只需要能够每天查看这 1-2 个查询,而不必为系统上的所有查询运行非常昂贵的配置文件,并且每天都需要深入研究它。
这可能吗?
I have what would seem to be an easy goal to accomplish, yet I have not found a good solution. Google does not shed a light on it and I just hope that I have been looking for a solution in wrong places or just tried to use tools in a wrong way...
Or perhaps it is already too late for me today to think clearly :) But this is where you can help me out, I hope.
I need to be able to log erroneous queries only which were executed on a specific instance of SQL Server. I thought that SQL Profiler would allow me to do it in no time, but I have not been able to find a combination of settings that would allow me to log only those queries, that returned an error (most likely parsing error) + error details.
Imagine SQL Server with 100s of queries being executed each second, and only 1 or 2 improperly formed queries each day resulting with a parsing error. I just need to be able to come and see those 1-2 queries per day without having to run a very expensive profile for all queries on the system and having to dig through it each day.
Is that possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设置异常事件类的跟踪,SQL:BatchCompleted 事件类 和 RPC:已完成事件类。添加
Error
不等于 0 的过滤器。启动跟踪。完毕。Set up a trace for the Exception Event Class, SQL:BatchCompleted Event Class and RPC:Completed Event Class. Add a filter for
Error
not equal to 0. Start the trace. Done.