--- title: "Extract a Script from a Trace (SQL Server Profiler) | Microsoft Docs" ms.custom: "" ms.date: "03/14/2017" ms.prod: sql ms.prod_service: "sql-tools" ms.service: "" ms.component: "sql-server-profiler" ms.reviewer: "" ms.suite: "sql" ms.technology: - "database-engine" ms.tgt_pltfrm: "" ms.topic: "article" helpviewer_keywords: - "scripts [SQL Server], traces" - "extracting script from trace [SQL Server]" ms.assetid: 431126a6-ff91-4818-8763-4442152bd571 caps.latest.revision: 20 author: "stevestein" ms.author: "sstein" manager: "craigg" --- # Extract a Script from a Trace (SQL Server Profiler) [!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)] This topic describes how to extract [!INCLUDE[tsql](../../includes/tsql-md.md)] events from a trace file or table and save them as a [!INCLUDE[tsql](../../includes/tsql-md.md)] script file by using [!INCLUDE[ssSqlProfiler](../../includes/sssqlprofiler-md.md)]. ### To extract a Transact-SQL script from a trace file or table 1. Open a trace file or table that contains [!INCLUDE[tsql](../../includes/tsql-md.md)] events that you want to save to a [!INCLUDE[tsql](../../includes/tsql-md.md)] script file. For more information, see [Open a Trace File (SQL Server Profiler)](../../tools/sql-server-profiler/open-a-trace-file-sql-server-profiler.md) or [Open a Trace Table (SQL Server Profiler)](../../tools/sql-server-profiler/open-a-trace-table-sql-server-profiler.md). 2. On the **File** menu, point to **Export**, point to **Extract SQL Server Events**, and then click **Extract Transact-SQL Events**. 3. In the **Save As** dialog box, type a name for the [!INCLUDE[tsql](../../includes/tsql-md.md)] file, and click **Save**. ## See Also [SQL Server Profiler](../../tools/sql-server-profiler/sql-server-profiler.md)