Monday, May 11, 2009

SQL Server Profiler - Not all templates contain database filter

In my continuing studies on .Net development, I am reading Programming Entity Framework by Julia Lerman. In one of the early chapters Julie referenced the SQL Profiler. Not having ever tried that particular tool, I fired it up and gave it a try (naturally without reading anything first -- just testing to see how intuitive the tool might be, of course). I found it catching a lot of things, but wasn't able to find my test query from one of the book's exercises in there.

I decided it must have a way of filtering, so I poked around and found a button with the word filter on it on the "Events Selection" tab. I thought I'd filter on the database, but discovered that there didn't seem to be a way to do it. I searched the web and found some examples, but they all seemed to have filter selections different from mine. I looked for videos, but the ones I saw also had the database nicely displayed in the Edit Filter dialog.

I finally found a post which explained that one had to have the database column set up to be displayed in the results before you could filter on it and the easiest way to do this was to start with the tuning template and follow the procedure:

Assuming you have the Tuning template selected, to filter:

  • Click the "Events Selection" tab
  • Click the "Column Filters" button
  • Select "DatabaseName", click the plus next to Like in the right-hand pane, and type your database name.
It's one of those things that becomes obvious once you realize it, but isn't the first time you are confronted with the big blank grey screen of SQL Server Profiler.