How to debug SQL Server T-SQL in Visual Studio 2012

nekno picture nekno · Aug 18, 2012 · Viewed 25.5k times · Source

How does one debug a T-SQL stored procedure in a multi-tier application in Visual Studio 2012?

To be clear, I want to set a breakpoint in a sproc in VS 2012, and hit it when the sproc is called from an ASP.NET WebForms app in the same debugging session.

When following the same steps as for VS 2010, the breakpoints aren't hit inside the sproc.

Debugging T-SQL in a sproc on a SQL Server 2008 R2 Express database works as expected in Visual Studio 2010.

To be sure everything was enabled properly, I went over the instructions for VS 2010 (here), but no such page exists for VS 2012 or .NET 4.5.

It seems the missing step is to enable "Application Debugging", but no such option exists in the Server Explorer > Data Connections context menu in VS 2012.

VS 2010 Application Debugging

enter image description here

VS 2012 No Application Debugging

enter image description here

Answer

Hunter picture Hunter · Nov 22, 2012

You need to open "SQL Server Object Explorer. Not "Server Explorer". That is what is different between 2010 & 2012. Then right click on the server and select "Application Debugging".