views:

160

answers:

1

I'd like to create a single trace file using SQL Profiler that spans several days so I can run it through DTA to get some advice on indexes. My issue is that I would be doing this on my laptop, which i shutdown and take home everynight, so i can't just pause it when i leave and start it when i get back. Also the server is taken down everynight.

Is there a way to concatenate trace files or start a new trace in the morning that writes to the end of the last trace file? Alternatively could i pass multiple trace files to DTA?

+1  A: 

In Profiler, use the "Script Trace" option, and then create the trace on the server. You can stop it in a few days' time and query it to your heart's content. It's actually less impact on the server, because it doesn't have to handle talking to the UI on your system.

Rob Farley
Excellent, sounds like this is what i'm looking for. Just to double check, the server being taken down won't affect this trace file?
Abe Miessler
Yes, it will. You should put the script into a stored procedure, and then mark the stored procedure to run on startup using: `EXEC sp_procoption 'someProc', 'STARTUP', 'ON'`
Rob Farley
Hmmm can you point me anywhere that has info on running profiler by script? I've only used the GUI.
Abe Miessler
Found some info on running without the GUI here if anyone is interested: http://msdn.microsoft.com/en-us/library/ms190362.aspx
Abe Miessler
Set up the trace in Profiler, and then look in the File menu to save the script.
Rob Farley