Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 3.52 KB

tracing-and-replaying-events.md

File metadata and controls

53 lines (35 loc) · 3.52 KB
title description author ms.author ms.date ms.service ms.topic helpviewer_keywords monikerRange
Tracing and Replaying Events
Tracing and Replaying Events
markingmyname
maghan
03/14/2017
sql
reference
replaying events
traces [SMO]
events [SMO], replaying
events [SMO], tracing
=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

Tracing and Replaying Events

[!INCLUDE SQL Server ASDB, ASDBMI, ASDW]

In SMO, the Trace and Replay objects in the xref:Microsoft.SqlServer.Management.Trace namespace provide programmatic access to the [!INCLUDEssSqlProfiler] functionality, which is used for monitoring an instance of [!INCLUDEssNoVersion] or [!INCLUDEssASnoversion]. You can capture and save data about each event to a file or table to analyze later. For example, you can monitor a production environment to see which procedures are impeding performance by executing too slowly.

The Trace and Replay objects provide a set of objects that can be used to create traces on an instance of [!INCLUDEssNoVersion]. These objects can be used from within your own applications to create traces manually for [!INCLUDEssNoVersion] or [!INCLUDEssASnoversion]. Additionally, SMO Trace objects can be used to read SQL Trace files and tables that were created by monitoring [!INCLUDEssNoVersion], [!INCLUDEssASnoversion], or DTS logging.

SMO Trace objects let you perform the following functions:

  • Create a trace.

  • Set filters on the trace.

  • Set the events that are being traced.

  • Stop or start a trace.

  • Read trace files, and trace tables.

  • Get information about events on a trace.

  • Get information about filters on a trace.

  • Manipulate trace data programmatically.

  • Write trace tables and trace files.

  • Replay trace files or trace tables.

The trace data from the Trace and Replay objects can be used by the SMO application, or it can be examined manually by using SQL Server Profiler. The trace data is also compatible with the SQL Trace stored procedures that also provide tracing capabilities.

The SMO trace objects reside in the xref:Microsoft.SqlServer.Management.Trace namespace, which requires a reference to the Microsoft.SQLServer.ConnectionInfo.dll file.

The Trace and Replay objects require a ServerConnectionxref:Microsoft.SqlServer.Management.Smo.Server.%23ctor%2A object to establish a connection with the instance of [!INCLUDEssNoVersion]. The ServerConnection object resides in the Microsoft.SqlServer.Management.Common namespace, which requires a reference to the Microsoft.SQLServer.ConnectionInfo.dll file.

Note

The Trace and Replay objects are not supported on a 64-bit platform.