Search code examples
sqlsql-server-2005debuggingsqlcmd

SQL debug print


If you have 100 occurrences of "PRINT" in your stored procedure, is there a nice way to turn them all on/off when debugging an non-debugging?

I could add a variable @isdebug = 1

and later on, do something like IF @isdebug = 1 PRINT @yourvar

and then just set the @isdebug to 0 or 1 depending on what you need. Is there a nicer way to do this?


Solution

  • Nope, that is also what I have in procs

    IF @debug = 1
    BEGIN
    print 'Something'
    --or insert into a log table if you need the rows of a temp table 
    --or the results of a calculation
    END