sqlsql-servervisual-studio

Cannot step into SQL Server stored procedure in Visual Stuidio


I have inherited a SQL Server stored procedure that I need to step through, and since debugging is no longer in SSMS I'm trying to use Visual Studio 2019. Here are the steps I'm using. I open Visual Studio and choose continue without code. Then I create a new data connection, right click the db and choose "New Query".

I paste in this

EXEC _healthandwelfare_rev4
        @bachnumb = N'TMW20210306',
        @prenddate = N'03-06-2021',
        @includeunpaidfte = 1,
        @fullrecalc = 1

I then set a break point on it, and use the SQL menu to Execute with Debugger. The issue is it just runs the whole thing and never stops to give me the step options. Honestly really stumped here on what I'm missing.


Solution

  • You cannot debug a SP in Visual Studio by the way you are doing.

    1. In the First place you should have a database project and the SP definition in the project to debug step through it.
    2. You can debug the SP by pasting its definition,(the whole SP) and comment out the create procedure section and declare the input parameters on the top and assign values and place Break points at the top and debug it.
    3. If you are using Visuals Studio 2019 then the below link may be helpful to you Debug Stored Proc in VS2019