SQL Debugger in dbForge Studio for SQL Server

SQL Debugger is an advantageous feature of dbForge Studio for SQL Server allowing you to troubleshoot Transact-SQL scripts, stored procedures, triggers, and functions quickly and easily. Automated debugging capabilities take away the necessity to comb through the scripts in an attempt to find bottlenecks. Stop compromising on code quality with T-SQL Debugger incorporated into Studio for SQL Server.

T-SQL Debugger functionality

With T-SQL Debugger, you can benefit from the support for step-by-step execution, call stack browsing, breakpoints, and watches. Debugging your code right in the IDE, you save time and effort, avoid performance issues, and minimize downtime.

T-SQL Debugger integrated into dbForge Studio for SQL Server allows debugging:

  • Stored Procedures
  • Triggers
  • Stored Functions
  • SQL scripts
  • Complex SQL queries

SQL Debugger permits going through the code line by line, stepping in and out routines, procedures, and functions. The tool supports single-stepping, pausing and setting breakpoints within the code, making it easy to evaluate variables and analyze the changes in their values.

SQL debug

Debugging a Stored Procedure

T-SQL Debugger provides all the necessary facilities for you to interactively debug stored procedures right in the IDE using traditional debugging operations such as:

  • setting breakpoints
  • evaluating and editing variables
  • examining the call stack
  • stepping into, out, and over individual statements
  • suspend the execution of your program, etc.
The Transact-SQL Debugger tool is well elaborated to suit the most demanding needs. The Call stack window allows tracking calls to nested procedures. The Watches window in its turn gives a possibility to evaluate SQL stored procedure variables and parameters.
SQL debugging - SQL Server debug stored procedure

Debugging a Trigger

To ensure that your trigger is running correctly and that it is called correctly, you might need to debug it. Debugging triggers can be tortuous as they perform complex operations silently.

If your trigger is fired by a stored procedure, you can debug both database objects as a whole, stepping into or over a trigger.
Debug SQL Server - Trigger

Debugging a Stored Function

Functions are generally not so easy to diagnose and debug. The Debugger tool that comes with dbForge Studio for SQL Server allows investigating the run-time behavior of your functions and spotting logic errors on-the-fly.

To debug a function, open the procedure calling that function and insert a breakpoint for the function you want to debug. Then start debugging. Step through the code using the F11 key or the Step Into button, or press CTRL+F5 to move directly to the breakpoint. Press F11 or click Step Into to get inside the stored function. Clicking the Step Over button, you will continue stepping through the stored procedure.
SQL debug - Function debugging

Debugging an SQL Script

Debugging large and complex SQL queries can be a daunting task. The script execution causes errors but they do not directly point at the problematic places in the script. Here T-SQL Debugger built into dbForge Studio for SQL Server comes to the aid.

To debug an SQL script, just open it in the SQL Editor and start debugging. Then set breakpoints to the statements if required. If a statement is invalid, an error message appears in the error list, though the debugging process continues. You can suspend the debugging of a query by selecting the Stop Debugging command from the Debug menu. You can also use different step commands to trace an SQL script.

The Call Stack and the Watches windows are also available for this debugging task.

Debug SQL query in SQL server

Execution Control

For the users' convenience, the Transact-SQL Debugger functionality of dbForge Studio for SQL Server can boast a number of control techniques allowing you to manage the debugging stored database objects.

Step Into
If the line of the code contains a function call, the debugger will enter the called function and continue line-by-line debugging there.

Step Over
In case the line contains a function call, the function will be executed and the result returned without debugging each line.

Step Out
Use the Step Out command, if you are inside a function and want to return to the preceding stack frame.

Continue, Stop debugging, and Restart commands allow you to directly control the flow of the debugging process.

MS SQL debug stored procedure - debugging execution control