SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
Robert Cearley
Robert Cearley
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 22
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.
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)SSC Guru (98K reputation)

Group: General Forum Members
Points: 98097 Visits: 33014
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

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Steve Jones
Steve Jones
SSC Guru
SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)SSC Guru (145K reputation)

Group: Administrators
Points: 145829 Visits: 19425
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.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Robert Cearley
Robert Cearley
Valued Member
Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)Valued Member (63 reputation)

Group: General Forum Members
Points: 63 Visits: 22
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...
Lowell
Lowell
SSC Guru
SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)SSC Guru (71K reputation)

Group: General Forum Members
Points: 71364 Visits: 40930
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!
siddharth.malhotra
siddharth.malhotra
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 2
Yes, Lowell

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

Regards,

Sid
mtassin
mtassin
SSCertifiable
SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)SSCertifiable (7.2K reputation)

Group: General Forum Members
Points: 7236 Visits: 72521
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
For tips on how to post your problems
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search