I am debugging stored procedures, and right now I am interested in what ran in what order and which which parameters as opposed to how fast things ran and what may sneak in between and cause a slowdown.
So, I captured a couple of minutes worth of trace. The problem is that there is too much stuff, and I need to narrow it down. If I do File -> Save As
, I get the following options:
Now, these are decent options, but what I really want is a tabular format, such as CSV. I think that commas in SP trace would probably mess up the CSV format. I would gladly use something else, such as ||
as a delimiter.
Once I do have the tabular format, I can filter it down using grep
, etc. and then easily process it with Python to see the exact things I want. I started parsing the XML file with a script, but found myself spending too much time on the trace XML
file format (have not used lxml
library before).
So ... is there an easier way? Can I at least copy it to Excel somehow?
If you save it into a trace table; you can get the data in a table in SQL Server which will let you manipulate it to your hearts content; including dumping it out to CSV if still required. The text data column is fully represented in the table.
If you choose Save → Trace Table. You will be prompted for the name of the table and the database. Lets say you call it ProfilerTemp in the database scratch.
Enter those; you can query the table using
select * from scratch.dbo.ProfilerTemp
You will see everything in the trace window in the table. If you didnt filter down to just stored procedures and want just them in the select
Select textdata from [Scratch].[dbo].[ProfilerTemp]
where eventclass = 10
And textdata like 'exec %'
and not cast(TextData as nvarchar(max))= 'exec sp_reset_connection'
This filters out non procedure calls and any connection resets you may have. You may need to add more filters depending on what you are trying to do.
If you want this out as a text file; choose query - results to file and run the query. This will prompt for the file name and give you the parameter text as a text file.