June 9, 2013 at 10:32 pm
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
June 10, 2013 at 12:02 am
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.
June 10, 2013 at 6:41 am
You can use the RAISERROR Statment with the NO WAIT option to achieve the behaviour you want.
June 10, 2013 at 4:46 pm
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
Change is inevitable... Change for the better is not.
June 10, 2013 at 4:56 pm
Krishna1 (6/9/2013)
Dear AllI 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
Change is inevitable... Change for the better is not.
June 10, 2013 at 10:21 pm
thanks it worked
June 11, 2013 at 3:44 am
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) 🙂
June 11, 2013 at 8:13 am
Krishna1 (6/10/2013)
thanks it worked
Excellent. Thanks for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply