13th October 2014

Tip: Retrieving SQL Commands from SQL Profiler

Tip: Retrieving SQL Commands from SQL Profiler

The Issue

So, the other day I am sitting around watching a bit of SQL Profiling on the old laptop, to see what a set of API requests were actually doing to a database, when I realised that there was no easy way to copy the all the executions into my documentation.

I tried all sorts from selecting all the rows and doing a copy and past to individually selecting just the execution rows and copying the statements from the preview window but I either ended up with statements in the wrong order or a stack of tabular data that turned to mush everytime a line feed was present.

All I wanted was the actual TextData column. Ah! I know, lets remove all the columns apart from that one and then copy and…… er no. All the columns were copied again.

By this point my head was hurting. Surely I am not asking for much here. Then, on came the lightbulb.  Dimely at first but within a few seconds was bright enough to mezmorise even the most streetwise of rabbits.

The Solution

Within the File | Save As menu is the option to save the trace as a table. Yep, a table. After that it was plain sailing with a sprinkle of complicated SQL (SELECT TextData FROM MyTrace) and a slice of copy and paste, I had my single column of data.  All that was left was remove the unwanted junk, using my good old friend Del, and job complete.

And there you go. A simple solution to what should be a simple task. I hope this tip is helpful and as usual, constructive critisism and suggestions are welcome.

Fill in this quick form and discover your digital future
Choose your interests:

Where to find us

We'd love to welcome you into our office! We're only 20 miles north of Peterborough, conveniently just off the A16.

Carver House
Apex Court, Elsoms Way
Pinchbeck
Lincolnshire
PE11 3UL