Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any tools available to create an executable tsql script from a SQL Server trace file?

Is there an easy manual way?

share|improve this question
Are you talking about the script to create the trace itself? – Shawn Melton Nov 17 '11 at 15:03
Profiler does it... – gbn Nov 17 '11 at 17:50
@MrHappy: need the trace definition (what Shawn asked) or about the script to get T-SQL events inside the trace? – Marian Nov 17 '11 at 20:25

You could use ClearTrace by Bill Graziano (free) which cleans up trace queries and allows you to sort/filter the trace files and still have a readable tsql from the trace.

Courtesy reference of Brent Ozar's presentation on "Using Perfmon and Profiler" at SQL Bits 2010

share|improve this answer

ClearTrace is a very nice tool that parses current trace files and shows easy aggregated reports on trace files data. But it doesn't script the trace file definition or T-SQL events.

In case you want to script the trace file definition to run it from a job, then you need to go to Profiler -> Filer -> Export -> Script Trace Definition - choose the needed SQL Server version. The result is a script with all the system procedures needed to create the same trace (on a different server or maybe at a later time, provided that you change some parameters like start/stop time, file names..etc).

In case you want to script the events inside the trace file, then you need to go to Profiler -> Filer -> Export -> Extract SQL-Server Events -> Extract T-SQL events. The result is a sql script with all procedures and batches ready to be executed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.