Mar 8, 2014

How to debug sql queries in SSMS (Sql server management studio)


How to debug sql queries in SSMS (Sql server management studio)

To debug a sql query in SSMS (sql sever management studio 2008 r2) 

Step 1: Add breakpoints in your query page of SSMS. For this click on left side bar as shown in following screen by red oval.


Step 2: Click on debug button or press Alt + F5. Debug button has shown in following screen by red oval:

Step3: To go next lines: 

Key     Meaning
F10  It is also called step over. It goes to next step but if query executes functions or stored procedures control will 

not go to inside function or stored procedure.

F11 It is also called step into.  It goes to next step but if query executes functions or stored procedures control will go 

to inside function or stored procedure. 

Alt + F5: It is called continue. If sql quires has more than breakpoints then control will move from one breakpoints to 

other directly and if no breakpoints then control move to end of the sql query.

Following figure shows continue,step over and step into buttons in ssms:

Step : Repeat the step 3 to go to the next steps. To know the current value of any local variables, put mouse over on that variable as shown in the following figure. Also at bottom in the Locals window you can get values and data type of the local variable. 


No comments:

Post a Comment