Query temp table in stored proc whilst debugging in SQL 2008 Management Studio

前端 未结 4 467
再見小時候
再見小時候 2020-12-31 01:43

I have a really large stored procedure which calls other stored procedures and applies the results into temp tables.

I am debugging in SQL 2008 Management Studio and

4条回答
  •  时光说笑
    2020-12-31 02:20

    an alternative would be to use a variable in your stored proc that allows for debug on the fly.

    i use a variable called @debug_out (BIT).

    works something like this

    ALTER PROCEDURE [dbo].[usp_someProc]

    @some_Var VARCHAR(15) = 'AUTO',

    @debug_Out BIT = 0

    BEGIN

      IF @debug_Out = 1
           BEGIN
                PRINT('THIS IS MY TABLE');
                SELECT * FROM dbo.myTable;
           END ................ 
    

    END

    the great thing about doing this is when your code launches your stored procedure, the default is to show none of these debug sections. when you want to debug, you just pass in your debug variable.

    EXEC usp_someProc @debug_Out = 1

提交回复
热议问题