skip to Main Content

I am trying to debug Microsoft SQL Server stored procedure from Visual Studio 2022. When I step into the code, I see what is shown in the screenshot. The actual stored procedure is not getting opened.

Is there any solution for this? SQL Server is on the same PC as my Visual Studio.

enter image description here

2

Answers


  1. Your question-post didn’t say if you’re using the Start Debugging command from within an SSDT (.sqlproj) project – or if you used the Attach to Process command to attach-to and debug sqlservr.exe.

    …but I assume the latter…

    …in which case, before you attach to sqlservr.exe you need to ensure you’ve selected only T-SQL Debugging, like so:

    enter image description here

    Login or Signup to reply.
  2. I am having the same problem.

    We recently upgraded to VS 2022 Pro from VS 2019 Pro. I have both versions installed.

    To do some testing of this issue, I made a copy of my VS 2022 workspace (ws-2022) using Windows Explorer. The new copy is called ws-2019.

    I did not change anything in the new workspace. The contents of two workspaces are identical.

    I want to debug the SP named MySP that is called from following SQL script:

        USE [MYDB]
        GO
        
        DECLARE @return_value Int
        
        EXEC    @return_value = [dbo].[MySP]
                @xmlData = N'<d><part>PART1</part></d>'
        
        SELECT  @return_value as 'Return Value'
        
        GO
    
    1. I opened the SLN file in ws-2019 using VS2019. VS opens.
    2. File -> Open -> File <SQLScript.sql> opens the SQL file.
    3. SQL -> "Execute with Debugger" menu item starts debugging.
    4. I pressed [F10] to STEP OVER until I got the EXEC statement.
    5. I then pressed [F11] to STEP INTO the SP.

    It worked fine in VS2019. The SQL code appeared and I was able to debug.

    I do the same process using VS2022 in the ws-2022 workspace and it fails.

    I get the same error as OP when I press [F11] at the EXEC.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search