Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Disable print in a stored procedure - TSQL - Example: Print 'This is my result' Expand / Collapse
Author
Message
Posted Wednesday, January 30, 2008 7:31 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 31, 2008 11:55 AM
Points: 11, 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.
Post #449381
Posted Wednesday, January 30, 2008 7:39 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 7:03 AM
Points: 15,738, Visits: 28,146
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #449388
Posted Wednesday, January 30, 2008 7:51 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 11:23 PM
Points: 33,278, Visits: 15,449
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
Post #449398
Posted Wednesday, January 30, 2008 8:01 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 31, 2008 11:55 AM
Points: 11, 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...
Post #449411
Posted Thursday, January 31, 2008 10:55 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:30 PM
Points: 12,918, Visits: 32,089
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #450093
Posted Friday, November 4, 2011 1:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, March 31, 2012 12:53 PM
Points: 1, Visits: 2
Yes, Lowell

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

Regards,

Sid
Post #1200863
Posted Friday, November 4, 2011 2:57 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, September 12, 2014 8:38 AM
Points: 3,675, Visits: 72,434
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
Post #1200914
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse