SQL Server 2008 - 捕获所有到达服务器的 SQL 语句
除了运行 Profiler 之外,任何人都可以建议我们在捕获发送到 SQL Server 的所有 SQL 语句时可能使用的选项吗?我知道有几种方法可以做到这一点,但想确保我没有忽略某些东西,例如现有的 DM 视图等。
非常感谢。
Can anyone suggest options we might have in capturing all SQL statements being sent to our SQL Server, outside of running Profiler? I'm aware of a couple ways of doing it, but want to make sure I'm not overlooking something, such as an existing DM view etc.
Thanks very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
SQL Server 2008 中的扩展事件。这些似乎未得到充分利用。也许是由于缺乏 UI 支持,但比 SQL 跟踪更灵活(更多事件和更好的过滤可能性)更轻量(由于更好的过滤和删除事件而不是阻止的可能性)
示例语法如下。不过,还有更多的事件、动作、谓词和输出目标的可能性。
并查看结果
Extended Events in SQL Server 2008. These seem fairly underused. Perhaps due to a lack of UI support but are more flexible than SQL Traces (more events and better filtering possibilities) more light weight (due to better filtering and possibility to drop events rather than block)
Example syntax is below. There are lots more events, actions, predicates and output target possibilities than that though.
And to review the results
如果 Profiler 的问题不是您不想使用它,而是您无法使用它,也许您可以使用 Microsoft SQL Server 2005/2008 Express Edition 的探查器 它是免费且开源的。
If your problem with Profiler isn't that you don't want to use it, but that you can't use it, perhaps you could use Profiler for Microsoft SQL Server 2005/2008 Express Edition It's free and open source.
我认为您的选择是
有一些 DMV 可以收集长时间运行的查询等信息,但我认为没有一个可以收集长时间运行的查询等信息。会给你一切。
I think your options are
There are DMV's that collect information such as long running queries, but I don't think that there is one that will give you everything.
您可以使用跟踪以编程方式捕获输出:以编程方式从 SQL Server 2005 接收分析器事件(实时)
You can use Tracing to capture the output programmatically: Programmatically receiving profiler events (in real time) from SQL Server 2005
就其价值而言,《深入了解 Microsoft SQL Server 2008 T-SQL 编程》一书有一个由 Greg Low 撰写的精彩章节,介绍了 SQL Server 2008 中的所有日志记录和审核选项。它讨论了每个选项何时应该使用以及每个的优点和缺点。话虽如此,你所做的可能是最好的。
For what its worth, the book "Inside Microsoft SQL Server 2008 T-SQL Programming" has a GREAT chapter written by Greg Low that looks at all of the logging and auditing options in SQL Server 2008. It discusses when each should be used and the pro and cons of each. Having said that, what you have done is probably best.