One of the things I found annoying with SQL Profiler (for SQL Server 2005) was that it would give me the traces of all the transactions that are happening on the server. I would not argue if its good or bad, however, I found it annoying while debugging, simply because I had to search through the junk to see where my code was being executed. So, to overcome that issue, I created a new template for SQL Profiler that would only show me data that was transmitted from my computer for a database of my choice. Here's how I did it.
Creating the template
- Fire up SQL Profiler
- Click on the "New Template" icon or choose from "File -> Templates -> New Template"
- Your screen should look like this
- Give a name to the sample template... say "AdventureWorksTracer". The idea is to get only "AdventureWorks" related trace messages originating from your computer.
- Also, under the "General" tab, check the "Base new template on existing one" and pick "TSQL_SPs" from the drop-down menu. Your screen should look like this.
- Click on the "Events Selection" tab. The default view would look like
- Check the "Show all columns" checkbox. This will add more columns to the visible area of the screen, and also give us more options in the "Column Filters"
- Click on "Column Filters" button, and set the database name as "AdventureWorks"
- Further down on the left side of the window, search for "Hostname" (this will come only if you checked the "Show all columns" in step 7). In the hostname, add your computer name (you can find out your computer name by right clicking on "My Computer" -> Properties -> Computer name )
- Click Ok to close this window. Finally click on Save to close the template design window as well. You may choose any extra columns you want before you close it though.
- TADA... you are done now. All you need to do now is to use this new template.
Using the template
- In SQL Profiler, File -> New Trace
- In the screen that looks like this
select your newly created template. - Click Run, and debug your way to glory.
Advantages:
- I get to see less junk coming from fellow developers.
- My database name filter based template helps me start up a template for one database alone (obviously I will be working on one db at any point of time)