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

Delay in Print Expand / Collapse
Author
Message
Posted Sunday, June 9, 2013 10:32 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, April 27, 2014 7:55 PM
Points: 218, Visits: 556
Dear All

I have procedure A,B,C. Procedure A calls B and C. Procedure B and C have loops and print statement in the loop (for me to understand whats happning). These procedure also have SEELCT (since its under testing phase all these selet and print) before loop.
But I have noticed that thouch the prints of B are not completly displayed it runs the Procedure C and displays SELECT result of C
And after some time it displayes remaining prints of B.

I am not able to understand this behaviour. As per my knowledge everything of B should get over and then only it should start with C.

Can anybody please explain me the reason of this behaviour

Regards
Post #1461381
Posted Monday, June 10, 2013 12:02 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 11:53 AM
Points: 23,081, Visits: 31,610
The print statements are buffered. You won't see them until the buffer is full and the OS (or is it actually SQL Server, not sure) sends them to SSMS.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1461396
Posted Monday, June 10, 2013 6:41 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
You can use the RAISERROR Statment with the NO WAIT option to achieve the behaviour you want.
Post #1461513
Posted Monday, June 10, 2013 4:46 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 11:28 AM
Points: 36,786, Visits: 31,244
OTF (6/10/2013)
You can use the RAISERROR Statment with the NO WAIT option to achieve the behaviour you want.


You should probably tell the "rest of the story" there.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1461809
Posted Monday, June 10, 2013 4:56 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 11:28 AM
Points: 36,786, Visits: 31,244
Krishna1 (6/9/2013)
Dear All

I have procedure A,B,C. Procedure A calls B and C. Procedure B and C have loops and print statement in the loop (for me to understand whats happning). These procedure also have SEELCT (since its under testing phase all these selet and print) before loop.
But I have noticed that thouch the prints of B are not completly displayed it runs the Procedure C and displays SELECT result of C
And after some time it displayes remaining prints of B.

I am not able to understand this behaviour. As per my knowledge everything of B should get over and then only it should start with C.

Can anybody please explain me the reason of this behaviour

Regards


As has been suggested, you can use RAISERROR instead of PRINT statements. There's a catch, though. You have to use a "severity" of 10 or less (preferably just "0" so you know it's a PRINT substitution instead of a real error) and you have to use WITH NOWAIT. The reason for the "severity" of 10 or less is so that it doesn't actually raise an error.

Here's the simple syntax...

RAISERROR('Your message here.',0,1) WITH NOWAIT;

In the above, the "0" is the severity and the "1" is really just a marker (State) which can be assigned just about any number. Most people leave it at 1.

Now, before you go using it for a "instant" PRINT statement, please go look it up in "Books Online" so that you know of ALL the other wonderful things you can do with this remarkable statement especially when it comes to some of the "printf" options.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1461813
Posted Monday, June 10, 2013 10:21 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, April 27, 2014 7:55 PM
Points: 218, Visits: 556
thanks it worked
Post #1461857
Posted Tuesday, June 11, 2013 3:44 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
Jeff Moden (6/10/2013)
OTF (6/10/2013)
You can use the RAISERROR Statment with the NO WAIT option to achieve the behaviour you want.


You should probably tell the "rest of the story" there.


Darn, I was just going to, but someone's gone and done it (better than I would have)
Post #1461964
Posted Tuesday, June 11, 2013 8:13 AM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 11:28 AM
Points: 36,786, Visits: 31,244
Krishna1 (6/10/2013)
thanks it worked


Excellent. Thanks for the feedback.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1462157
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse