Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to disable print output from within sp

Status
Not open for further replies.

TWillard

Programmer
Apr 26, 2001
263
US
I have a tsql stored procedure that contains print statements. I was wondering if there is a tsql command that I can include in the stored procedure that would disable/enable these output statements? Sometimes, I want to see the output like when I am developing in the procedure. However, I don't want to see the output when the procedure is executed by an application. It would be nice to turn these off without having to comment and uncomment these statements.
 
I believe you have to comment out the print statements, and recompile the procedure to stop the print outputs.
 
Yes, just add one more parameter to that SP named @debug. Make it BIT and set its default to 0 (zero). Then put all print statements in IF clause. Something like that:

Code:
CREATE PROCEDURE MySP(
       @Par1 int,
       @Par2 varchar,
       @Debug bit = 0
)
AS
 BEGIN
     ....

     IF @Debug  = 1
        print 'Something'

     ......

     IF @Debug  = 1
        print 'Other thing'

 END

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top