How to Check or Trace Select statements fired or executed on Microsoft SQL Server database using SQL profiler tool

Hi Everyone, this is a post on using SQL Profiler to check the Statements executed on SQL Server DB.
In this post I have tried to put very less theory and have tried to explain with screenshot. Hope you will find this approach useful.
This technique not only shows Standalone Select statements executed but also the Select statements executed inside Stored Procedures.

Step 1) Open SQL Profiler - In SQL Server Management Studio -> Click on Tools Menu and Select - SQL Server Profiler


Step 2) Under General Tab -> Select “Blank” Template in the “Use the template” drop down
If “Blank” Template is not available in the drop down select “Tuning” template from the drop down.



Step 3) Under Event Selection Tab -> Check the check box for "SQL-StmtCompleted" this is present under the TSQL Category as shown below and Uncheck all other check boxes 
(Unchecking others is optional this is done to limit the information being display for other types of Events)



Note – If "SQL-StmtCompleted" is not visible, then check the check box - "Show all events" in the Left had corner this will display all the Events and select the required Event.

Step 4) Click on Column Filters button -> Under TextData -> Like -> Enter the text  “SELECT%”



Step 5) Click on Column Filters button -> Under "DatabaseName" -> Like -> Enter the Database Name (Here - TestDatabase) and click OK and RUN button.
This will start the Sql profiler window where we can see the Stored Procedures fired on the selected database.

No comments: