Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are multiple ways to capture every SQL statement that is being executed on a SQL Server 2008 instance:

  1. SQL Server Profiler: SQL Server Profiler is a graphical tool that allows you to capture and analyze SQL Server events. It provides a rich set of trace templates that you can use to capture SQL statements, stored procedures, and other events. To capture every SQL statement that is being executed, you can create a trace that captures the TSQL:BatchCompleted and TSQL:StmtCompleted events.

  2. Extended Events: Extended Events is a lightweight event infrastructure that provides low overhead tracing for SQL Server. You can use Extended Events to capture SQL statements, stored procedures, and other events. To capture every SQL statement that is being executed, you can create an Extended Events session that captures the sqlserver.sqlstatementcompleted event.

  3. SQL Server Audit: SQL Server Audit is a feature that allows you to audit events and actions that occur on the server. You can use SQL Server Audit to capture SQL statements, stored procedures, and other events. To capture every SQL statement that is being executed, you can create an audit that captures the SQL:BatchCompleted and SQL:StmtCompleted events.

  4. SQL Server Trace: SQL Server Trace is a deprecated feature that allows you to capture and analyze SQL Server events. It provides a scriptable interface that you can use to create custom traces. To capture every SQL statement that is being executed, you can create a trace that captures the SQL:BatchCompleted and SQL:StmtCompleted events.

Note: Capturing every SQL statement that is being executed can generate a large amount of data, which can impact the performance of the server. It's important to design your trace or audit carefully to minimize the impact on the server.