Thank this author by sharing:
By Dan Guzman,
Welcome to the Stairway Series on Tracing in SQL Server. Traces are defined and managed using sp_trace* stored procedures, regardless of whether one uses the Profiler graphical interface or a T-SQL script to accomplish the task. The same trace system stored procedures that Profiler calls internally can be executed directly from a T-SQL script to create a server-side trace that runs independently of Profiler.
Prerequisites: A solid familiarity with SQL Server Profiler as well as familiarity with T-SQL querying, including multi-table joins. A basic understanding of SQL Server metadata will also help you understand the material presented in this series.
Step 1: Overview of Tracing - A general overview that talks about the basics of the SQL Trace system, basic architecture, the Profiler GUI, and server vs. client side tracing.
Step 2: Creating a SQL Trace Using T-SQL - In this level we will look at how you can create your own traces using T-SQL to code the events and filters. This level also covers starting and stopping the trace as well as viewing the data.
Step 3: Creating a Trace using SQL Server Profiler - Creating a custom trace by hand can be a cumbersome exercise, but in this step we will show you how to easily use the Profiler GUI to create a trace and then save that definition as T-SQL.