How do you debug or step through the code in SQL Server Management Studio 18?

Viewed 26766

SQL Server Management Studio used to have Debug functionality that would allow to step through the code and watch the values etc. Referring to How to add the Debug button to SSMS v18?, I understand that the functionality is removed from SQL Server Management Studio V18.1.

But what is the alternative now? How do you step through the code to pinpoint a bug in the code?

4 Answers

You can use Visual Studio (the full IDE) to do it:

  1. Use "Server Explorer" (Under the View menu) to connect to your DB
  2. Right-click the DB and choose "New Query" (or find a stored procedure to debug)
  3. Set a break point (F9 key or otherwise) on a line of SQL
  4. Right-click inside the SQL editor and choose "Execute with Debugger"

Ta for answer above, but when trying to debug with Sever Explorer, I find that "SQL Debugging is not supported on Microsoft Azure SQL Database'... ho hum, so I downgrade to SSMS 17.9 or dump the database to local and do it there.

Nice, I just wanted to quickly debug something... by the time I've done that lot I'll have forgotten what the problem I was trying to fix was !

Your best option is to not upgrade version 18.X, but stay on 17.9 until the Microsoft Product Manager gets sacked. A similar thing happened in going from SQL Server 2000 to SQL Server 2k5. Eventually, they capitulated and re-introduced the feature.

It's deprecated, so you don't. Personally, I never use the feature and I'm assuming many others didn't either (which is why it's being retired).

The work around is to debug stored procedures by outputting values using PRINT or RAISERROR. Using BEGIN TRAN / ROLLBACK this works well because you can easily run code against the same data.

It's not the same as step through debugging, but it works.

Related