Skip to Content

Debugging Stored Procedures

By Craig Cmehil

Leveraging SQLScript in Stored Procedures & User Defined Functions

You will learn

In the following exercise we will show how to debug a procedure using the SQLScript debugger. This includes setting breakpoints, evaluating expressions and intermediate results.
Please note - This tutorial is based on SPS11


  1. Go to the HRTT page and open the procedure called dev602.procedures::get_po_header_data.

  2. From the menu, click SQL Debugger, then Debug Settings.

    SQL debugger
  3. For the service name, click the drop down box.

    service name
  4. Choose your container associated with your user id. Click “OK”.

  5. Click the “Connect” button.

  6. Click “Apply”, then “Close”.

  7. Set breakpoints at the lines shown here by simply clicking on the line number.

  8. Click “Invoke Procedure”.

  9. A new SQL tab will be opened. Click on the “Run” button.

    SQL tab
  10. Execution of the procedure has started, and a debugger pane is now visible which is displayed on the right. You can see all of the variables and parameters for this procedure. You might notice that this pane is currently not showing the intermediate table variables at this point.

    execute procedure
  11. Click the “Step Over” button.

    step over
  12. You will notice that execution has continued to the next statement. In the debugger pane, a new local variable has been added. This is because it is not defined explicitly will be implicitly declared at runtime during first usage.

    next step
  13. To see the data for this intermediate table variable, right click on it and choose “Display Content”.

    display content
  14. A new window is then opened showing the data in the table. Review the data and close the window by clicking the “X” in the upper right hand corner.

    review data
  15. Click the “Toggle Expression Editor” button.

    toggle expression editor
  16. In the yellow box that appears below, enter a SELECT statement as shown here and hit “Enter”.

    select statement
  17. You will notice the expression is then added to the “Expressions” section above.

  18. Right click on the expression and choose “Display Content”.

    display content
  19. Review the results and close the window by clicking the “X”.

    review results
  20. Once again click the “Step Over” button. Notice the next intermediate table variables is also added. You can review the data in this table as well.

    step over
  21. Continue to step through the code and when execution stops at the END statement of the procedure, display the contents of the output parameter the same way you did for the intermediate table variables. Finally, close the window by clicking the “X”.

    continue steps
  22. Click the “Resume” button.

  23. Execution of the procedure is now completed. Return to the SQL tab and check the results.


Next Steps

Updated 01/17/2017

Time to Complete

10 Min.



Next Steps

Back to top