运行 SQL Server ProfilerRun SQL Server Profiler

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions)

可以通过多种方法运行 SQL Server ProfilerSQL Server Profiler ,以支持在各种情况下收集跟踪输出。You can run SQL Server ProfilerSQL Server Profiler in several different ways, to support gathering trace output in a variety of scenarios. 启动 SQL Server ProfilerSQL Server Profiler 的方法包括:从 Windows 10“开始”菜单启动、从数据库引擎Database Engine优化顾问中的“工具”菜单启动以及从 SQL Server Management StudioSQL Server Management Studio 中的多个位置启动 。You can start SQL Server ProfilerSQL Server Profiler from the Windows 10 Start menu, from the Tools menu in 数据库引擎Database Engine Tuning Advisor, and from several locations in SQL Server Management StudioSQL Server Management Studio.

首次启动 SQL Server ProfilerSQL Server Profiler 并从“文件”菜单中选择“新建跟踪”时,此应用程序将显示“连接到服务器”对话框,在该对话框中可以指定要连接到的 SQL ServerSQL Server 实例 。When you first start SQL Server ProfilerSQL Server Profiler and select New Trace from the File menu, the application displays a Connect to Server dialog box where you can specify a SQL ServerSQL Server instance to connect to.

从 Windows 10“开始”菜单启动 SQL Server ProfilerTo start SQL Server Profiler from the Windows 10 Start menu

  • 单击 Window“启动”图标或按 Windows 键,然后开始键入“SQL Server Profiler 17”。Click the Windows Start icon or press the Windows key and start to type"SQL Server Profiler 17". 显示“SQL Server Profiler 17”磁贴时,单击它。When the SQL Server Profiler 17 tile appears, click it.

在数据库引擎优化顾问中启动 SQL Server ProfilerTo start SQL Server Profiler in Database Engine Tuning Advisor

  • 数据库引擎Database Engine 优化顾问的 “工具” 菜单上,单击 SQL Server ProfilerOn the 数据库引擎Database Engine Tuning Advisor Tools menu, click SQL Server Profiler.

在 SQL Server Management Studio 中启动 SQL Server ProfilerTo start SQL Server Profiler in SQL Server Management Studio

可以从 SQL Server Management StudioSQL Server Management Studio 中的多个位置启动 SQL Server ProfilerSQL Server ProfilerYou can start SQL Server ProfilerSQL Server Profiler from several locations in SQL Server Management StudioSQL Server Management Studio. SQL Server ProfilerSQL Server Profiler 在启动时将加载连接上下文、跟踪模板及其启动点的筛选上下文。When SQL Server ProfilerSQL Server Profiler starts, it loads the connection context, trace template, and filter context of its launch point. SQL Server Management StudioSQL Server Management Studio 在自己的实例中启动每个 SQL Server Profiler 会话,在关闭 SQL Server Management StudioSQL Server Management Studio 的情况下,Profiler 仍继续运行。starts each SQL Server Profiler session in its own instance, and Profiler continues to run if you shut down SQL Server Management StudioSQL Server Management Studio.

从“工具”菜单启动 SQL Server ProfilerTo start SQL Server Profiler from the Tools menu

  • SQL Server Management StudioSQL Server Management Studio 的“工具”菜单中,单击“SQL Server Profiler” 。In the SQL Server Management StudioSQL Server Management Studio Tools menu, click SQL Server Profiler.

从查询编辑器启动 SQL Server ProfilerTo start SQL Server Profiler from the Query Editor

  • 在查询编辑器中右键单击,然后选择“在 SQL Server Profiler 中跟踪查询” 。In Query Editor, right-click and then select Trace Query in SQL Server Profiler.

    备注

    该连接上下文为编辑器连接,跟踪模板为 TSQL_SPs,应用的筛选器为 SPID = query window SPID。The connection context is the editor connection, the trace template is TSQL_SPs, and the applied filter is SPID = query window SPID.

从活动监视器启动 SQL Server ProfilerTo start SQL Server Profiler from Activity Monitor

  • 在活动监视器中,单击“进程”窗格,右键单击要探查的进程,然后单击“在 SQL Server Profiler 中跟踪进程” 。In Activity Monitor, click the Processes pane, right-click the process that you want to profile, and then click Trace Process in SQL Server Profiler.

    备注

    选定某个进程后,打开活动监视器时连接上下文为对象资源管理器连接。When a process is selected, the connection context is the Object Explorer connection when Activity Monitor was opened. 跟踪模板为基于服务器类型的默认模板,并且 SPID 等于所选进程的 SPID。The trace template is the default based on the server type, and the SPID equals the SPID for the selected process.

.NET Framework 安全性.NET Framework Security

  • 在 Windows 身份验证模式下,运行 SQL Server ProfilerSQL Server Profiler 的用户帐户必须拥有连接到 SQL ServerSQL Server 实例的权限。In Windows Authentication mode, the user account that runs SQL Server ProfilerSQL Server Profiler must have permission to connect to the instance of SQL ServerSQL Server.
  • 若要使用 SQL Server ProfilerSQL Server Profiler执行跟踪,用户还必须拥有 ALTER TRACE 权限。To perform tracing with SQL Server ProfilerSQL Server Profiler, users must also have the ALTER TRACE permission.

后续步骤Next steps

SQL Server Profiler 概述 SQL Server Profiler overview
使用 SQL Server Management StudioUse SQL Server Management Studio