a4aabi01
a4aabi01

Reputation: 9

How can I debug stored procedure step by step in sql server

How can I debug stored procedure step by step in SQL server...?? I put a break point in stored procedure and start debug , but I got an error like

"Unable to start T-SQL Debugging . Could not attach to SQL Server process on 'WCHN-210' Click help for more information"...

Upvotes: 0

Views: 4385

Answers (1)

gotqn
gotqn

Reputation: 43636

This is what I do:

  1. Script the procedure. You should get something like this:

    DROP PROCEDURE [dbo].[ups_Test]
    GO
    
    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    CREATE PROCEDURE [dbo].[ups_Test]
    @ParameOne int,
    @ParameTwo nvarchar(10)
    AS
    BEGIN
        -- Your code
    END
    
    
    GO
    
  2. Delete the "drop/create","begin/end" etc statements.

  3. Add a 'DECLARE' in front of each parameter and a value if it does not have default.

    DECLARE @ParameOne int=10,
    
    DECLARE @ParameTwo nvarchar(10)=''
    
    -- Your code
    

That's all - execute the statement and see where is the problem.

Upvotes: 1

Related Questions