Debug a stored procedure on Azure SQL Database
SQLTreeo T-SQL Debugger steps through a stored procedure on Azure SQL Database one statement at a time: sign in with Microsoft Entra ID, connect to the database, and see what is different from SQL Server.
Step through a stored procedure on Azure SQL Database one statement at a time with SQLTreeo T-SQL Debugger: sign in with Microsoft Entra ID, connect to the database, and press Debug. Nothing is installed on the server: the debugger reads the procedure and sends each statement over your connection.
Before you start
- The firewall. Azure SQL Database only accepts connections from addresses its firewall allows. If the connection is refused with a message about your IP address, add the address of your computer in the Azure portal, under the server’s networking settings.
- A test database. A debug session runs the procedure for real, with your rights, so a procedure that inserts rows really inserts them. Use a copy or a development database when you are not sure what the procedure changes.
- Rights to read the procedure. The debugger needs
VIEW DEFINITIONon the procedure to read its source. A procedure whose definition your login cannot read is greyed out in the Object Explorer. Statements run with your own rights: ownership chaining andEXECUTE ASdo not apply during a debug session.
Connect
- Start the debugger. At the first start the connection dialog opens. Otherwise press Connect… at the top left.
- Enter the server name, for example
myserver.database.windows.net. - Choose the authentication. For Azure SQL Database that is usually Microsoft Entra ID. SQL Server authentication also works when the server allows it.
- Fill in the Database field with the database that holds the procedure. Leave it empty and you land in the login’s default database, which is usually
master. - Press Test connection, then Connect. A connection that works is remembered and opens again at the next start.
One connection per database
On SQL Server the Object Explorer lists every database of the server. Azure SQL Database works differently: it does not allow USE, and it does not allow a look into the catalog of another database. So in the debugger every database is its own connection:
- Connected to a user database: the tree shows that database and
master. Azure lists the other databases frommasteralone. - Connected to
master: the tree lists every database of the server, one item each, with the text “Connect to this database to see its objects”. Opening it creates a new connection to that database.
Everything else is the same as on SQL Server. Under Programmability you find the stored procedures and functions of the database, and a double-click opens the code and writes the call in the Batch tab.
Step through the procedure
- Double-click the procedure in the Object Explorer, or select it and press Debug.
- In the Batch tab, fill in the parameters of the call.
- Press Into (F11) to stop at the first statement, or Start (F5) to run to the first breakpoint.
- Step with Into (F11), Over (F10) and Out (Shift+F11). The yellow arrow shows the next statement and the Variables pane shows the values, with what changed since the last stop in red.
Breakpoints (F9), conditions, watches, the query window and the pause on errors work as on SQL Server. See Breakpoints and watches and Pause on an error, fix it and retry.
Good to know
- Each statement is a round trip. The debugger sends the statements one at a time, so a loop that runs thousands of times takes a while over the internet. Give a breakpoint a condition, such as
@ItemId = 4, instead of stepping through the loop. - Some code runs but cannot be stepped into: dynamic SQL,
INSERT ... EXEC, triggers and multi-statement table-valued functions. - Tested on Azure SQL Database and on SQL Server 2025.
- Your code stays with you. Procedures, table data and connection details are not sent to SQLTreeo.
Next steps
- Download SQLTreeo T-SQL Debugger. The 30-day trial starts at the first start and has every feature.
- Getting started shows the first steps in more detail.
- Debug a stored procedure in SQL Server, one statement at a time walks through finding a bug with an example.