Disable print in a stored procedure - TSQL - Example: Print 'This is my result'

  • I have a stored procedure that has several statements like print 'This is the result'

    These statements are causing errors with other stored procedures that call it. I'm not permitted to modify the stored procedure that has the problem since it is part of a base product. Is there a way to turn off print so that when I call the stored procedure that has the print command, it doesn't print anything.

    Thanks.

  • I've never heard of anything that'll help. You'll either have to modify the procedure to disable the PRINT statements or you have to modify the code so that it can accept the informational messages along with result sets.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I'd say that you should wrap them in an IF clause, but if you can't add a parameter or logic, that might not help.

    Are the print statements used? If not, I'd comment them out and alter the proc so they don't execute.

    AFAIK, there's no way to prevent them if they're in code.

  • Yeah, the stored procedure can't be modified. It looks like the solution here may be to just copy the stored procedure without the print statements into another new proc. Thanks...

  • Interesting; I'd like to know how a PRINT statement affects the other procedures;I haven;t tripped over that yet, and do a lot of programming.

    Can you explain what goes wrong?

    Another idea: Could it be that your confusing print statement issues with "x Rows Affected" statements, which I know can mess up ADODB recordsets (that gets fixed easily by simply adding SET NOCOUNT ON at the top of each of the procedures )

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Yes, Lowell

    That is the problem. I need to disable the outputs like the ones you specified.

    Regards,

    Sid

  • siddharth.malhotra (11/4/2011)


    Yes, Lowell

    That is the problem. I need to disable the outputs like the ones you specified.

    Regards,

    Sid

    Did you try putting SET NOCOUNT ON before the stored procedure is executed?



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply