SQL Server Profiler - 如何过滤跟踪以仅显示来自一个数据库的事件?

发布于 2024-07-08 17:30:15 字数 75 浏览 7 评论 0原文

如何将 SQL Server Profiler 跟踪限制到特定数据库? 我看不到如何过滤跟踪以看不到我连接到的实例上所有数据库的事件。

How do I limit a SQL Server Profiler trace to a specific database? I can't see how to filter the trace to not see events for all databases on the instance I connect to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

迷爱 2024-07-15 17:30:15

在跟踪属性>下 事件选择选项卡> 选择显示所有列。 现在在列过滤器下,您应该看到数据库名称。 输入“Like”部分的数据库名称,您应该仅看到该数据库的跟踪。

Under Trace properties > Events Selection tab > select show all columns. Now under column filters, you should see the database name. Enter the database name for the Like section and you should see traces only for that database.

得不到的就毁灭 2024-07-15 17:30:15

在 SQL 2005 中,您首先需要在跟踪中显示数据库名称列。 最简单的方法是选择调整模板,该模板已添加该列。

假设您选择了调优模板,要进行过滤:

  • 单击“Events Selection”选项卡
  • 单击“Column Filters”按钮
  • 选中“Show all Columns”(右侧向下)
  • 选择“DatabaseName”,单击右侧“Like”旁边的加号窗格,然后键入您的数据库名称。

我也总是将跟踪保存到表中,这样我就可以在事后对跟踪数据进行 LIKE 查询。

In SQL 2005, you first need to show the Database Name column in your trace. The easiest thing to do is to pick the Tuning template, which has that column added already.

Assuming you have the Tuning template selected, to filter:

  • Click the "Events Selection" tab
  • Click the "Column Filters" button
  • Check Show all Columns (Right Side Down)
  • Select "DatabaseName", click the plus next to Like in the right-hand pane, and type your database name.

I always save the trace to a table too so I can do LIKE queries on the trace data after the fact.

貪欢 2024-07-15 17:30:15

在跟踪属性中,转到事件选择选项卡。 然后单击“显示所有列”单选按钮。 之后单击“列过滤器”按钮。
输入图像描述这里

现在您可以看到数据库名称属性并单击它。 展开类似框并插入您的数据库名称,然后单击“确定”,您现在可以运行分析器。

输入图像描述这里

In the Trace Properties go to the Event Selection tab. Then click on the Show All Columns radio button. After that click on the Column Filters button.
enter image description here

Now you can see the Database Name property and click on it. Expand the like box and insert your DB name and click ok and you can run the profiler now.

enter image description here

白云不回头 2024-07-15 17:30:15

通过实验,我能够观察到这一点:

当 SQL Profiler 2005 或 SQL Profiler 2000 与驻留在 SQLServer 2000 中的数据库一起使用时 - 提到的问题仍然存在,但是当 SQL Profiler 2005 与 SQLServer 2005 数据库一起使用时,它工作得完美!

总而言之,这个问题似乎在 SQLServer 2000 和 SQLServer 2000 中普遍存在。 在 SQLServer 2005 中得到纠正。

处理 SQLServer 2000 时问题的解决方案是(如 wearejimbo 所解释)

  1. 通过查询 sysdatabases 表来识别要过滤的数据库的 DatabaseID,如下所示

    <前><代码>选择 *
    FROM master..sys数据库
    WHERE name like '%your_db_name%' -- 删除此行以查看所有数据库
    按 dbid 排序

  2. 在 SQL Profiler 2000 的“新建跟踪”窗口中使用 DatabaseID 过滤器(而不是 DatabaseName)

By experiment I was able to observe this:

When SQL Profiler 2005 or SQL Profiler 2000 is used with database residing in SQLServer 2000 - problem mentioned problem persists, but when SQL Profiler 2005 is used with SQLServer 2005 database, it works perfect!

In Summary, the issue seems to be prevalent in SQLServer 2000 & rectified in SQLServer 2005.

The solution for the issue when dealing with SQLServer 2000 is (as explained by wearejimbo)

  1. Identify the DatabaseID of the database you want to filter by querying the sysdatabases table as below

    SELECT * 
    FROM master..sysdatabases 
    WHERE name like '%your_db_name%'   -- Remove this line to see all databases
    ORDER BY dbid
    
  2. Use the DatabaseID Filter (instead of DatabaseName) in the New Trace window of SQL Profiler 2000

做个ˇ局外人 2024-07-15 17:30:15

在“跟踪”属性中,单击顶部“常规”旁边的“事件选择”选项卡。 然后点击右下角的列过滤器...。 然后,您可以选择要过滤的内容,例如 TextDataDatabaseName

展开 Like 节点,然后使用百分比 % 符号(如 %MyDatabaseName%%TextDataToFilter%)输入过滤器。 如果没有 %% 标志,过滤器将无法工作。

另外,请确保选中复选框排除不包含值的行如果找不到要过滤的字段,例如DatabaseName,请转到常规选项卡并更改您的模板,空白模板应包含所有字段。

In the Trace properties, click the Events Selection tab at the top next to General. Then click Column Filters... at the bottom right. You can then select what to filter, such as TextData or DatabaseName.

Expand the Like node and enter your filter with the percentage % signs like %MyDatabaseName% or %TextDataToFilter%. Without the %% signs the filter will not work.

Also, make sure to check the checkbox Exclude rows that do not contain values' If you cannot find the field you are looking to filter such as DatabaseName go to the General tab and change your Template, blank one should contain all the fields.

徒留西风 2024-07-15 17:30:15

创建一个新模板并检查 DBname。 使用该模板作为您的跟踪文件。

Create a new template and check DBname. Use that template for your tracefile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文