執行 SQL Server ProfilerRun SQL Server Profiler

適用於: 是SQL Server 否Azure SQL Database 否Azure Synapse Analytics (SQL DW) 否平行處理資料倉儲 APPLIES TO: yesSQL Server noAzure SQL Database noAzure Synapse Analytics (SQL DW) noParallel Data Warehouse

您可以使用多種不同的方式來執行 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. 您可以從 Windows 10 的 [開始] 功能表、Database EngineDatabase Engine Tuning Advisor 的 [工具] 功能表,以及 SQL Server Management StudioSQL Server Management Studio 的數個位置啟動 SQL Server ProfilerSQL Server ProfilerYou can start SQL Server ProfilerSQL Server Profiler from the Windows 10 Start menu, from the Tools menu in Database EngineDatabase 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

  • 按一下 Windows [開始] 圖示或按 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.

在 Database Engine Tuning Advisor 中啟動 SQL Server ProfilerTo start SQL Server Profiler in Database Engine Tuning Advisor

  • Database EngineDatabase Engine Tuning Advisor 的 [工具] 功能表上,按一下 [SQL Server Profiler]On the Database EngineDatabase 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 ProfilerSQL Server ProfilerSQL Server Management StudioSQL Server Management Studio的數個位置開始。You 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 Tuning Advisor 中的 功能表上,按一下 [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 = 查詢視窗 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