How to debug T-SQL with SQL Server Management Studio 2017?
You just need to download the Visual Studio 2019 Community.
Once you've done that, create a new project and open the SQL Server Object Explorer (CTRL + S).
You will be able to see your list of SQL Server databases, just as you did in SQL Server Management Studio.
Finally, left click one database and select "New Query". Now you can debug T-SQL just as you did in SSMS.
But the debugger does not work with Azure SQL
@dens is correct by going to visual studio community edition however this is half of the answer as table variable values cannot be inspected and have the placeholder as (table); This is due to Microsoft not finishing this portion of the debugger. Currently, you can only see primitive data types outputted within the Locals Tab.
The work around to see table variables when they are deleted, updated or inserted into is to utilize the output keyword with each query to output the inserted or deleted elements. Now when you step through you will see the primitive variables within the debugger logger tab called "Locals" and the table variables within the Results or T-SQL tab as you step through. unfortunately the variable name will not be next to the output however as you step through, its pretty clear which table output belongs to which variable
Furthermore, if you are debugging a stored procedure on a SQL database not on your local database, i recommend backing up a local version of the database with the developer edition of SQL server since attaching a debugger to the query will get blocked by the firewall. Then you will require sysadmin privileges and open ports which may work however it did not work within my workplace. we tried even dropping the entire firewall and nothing but good luck.
- It seems that Microsoft may have temporarily moved the branch of debugging from SSMS18 to SQLServer Data Tools (SSDT).
- According to developers of DBA Stackexchange community, there is another alternative way to debugging, since Debugger is deprecated in SSMS18.
- Here is the link that shows how to achieve debugging : How to add the Debug button to SSMS v18?
ALTERNATIVE: ??
- Just when I thought there would be no solution to this coming out any time soon, to my surprise there might be one.
- There is a tool that I've come across lately while dabbling into this debugger thing in SSMS18 out of curiosity, which goes by the name SQL Complete.
- The company Devart apparently specializes in Database products and provides toolsplug-ins for various major databases.
- Here is a small video of them briefing about the debugging feature in their tool SQL Debugger in the new version of dbForge SQL Complete
- It's available on Visual Studio Marketplace.