473,802 Members | 2,228 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PRINT only takes effect after T-SQL completion ?

Hello All,

I have a stored procedure which will act like a main/controller script
which will then invoke more stored procedures (~20). Basically, it
looks something like below:

-- start script
create procedure ...
print 'process started'
exec sp_1
exec sp_2
exec sp_3
....
print 'process ended'
-- end script
Looking at it, after running that procedure, immediately I would expect
the first PRINT statement to be printed but it won't. It seemed
that the print statements would only display the messages after
the whole processing completed.

What's the reason for this sort of behaviour. If so, then we would
not be able to print any progress reporting in our scripts.

Please comment.
Thanks in advance.
Jul 20 '05 #1
4 14808
Insert a "go" after each print and it sould work.

-- start script
create procedure ...
print 'process started'
go
exec sp_1
print 'sp_1 finished'
go
exec sp_2

print 'sp_2 finished'
go
exec sp_3

print 'sp_3 finished'
go
....
print 'process ended'
-- end script
Jul 20 '05 #2
I believe that the messages will only appear once the implicit
transaction or proceedure has ended.

i.e

create procedure ...
print 'process started'
go
exec sp_1
exec sp_2
exec sp_3
...
print 'process ended'
go

It is too bad that you cannot use 'go' in a stored proceedure.

eh****@hotmail. com (James) wrote in message news:<46******* *************** ****@posting.go ogle.com>...
Hello All,

I have a stored procedure which will act like a main/controller script
which will then invoke more stored procedures (~20). Basically, it
looks something like below:

-- start script
create procedure ...
print 'process started'
exec sp_1
exec sp_2
exec sp_3
...
print 'process ended'
-- end script
Looking at it, after running that procedure, immediately I would expect
the first PRINT statement to be printed but it won't. It seemed
that the print statements would only display the messages after
the whole processing completed.

What's the reason for this sort of behaviour. If so, then we would
not be able to print any progress reporting in our scripts.

Please comment.
Thanks in advance.

Jul 20 '05 #3
If you're talking to SQLServer through an ODBC connection (what else?), the
ODBC protocol is really what's driving the batching of messages and result
sets.

PRINT statements, RAISERROR output, and system errors all reach the client
through ODBC SQLError(). Logically, all such messages are batched up until a
result set, or until the end of the RPC call (SQLExecute or SQLExecDirect).
The ODBC connection doesn't know anything about what procedures you're
calling. If you execute a PRINT command, then call a stored procedure that
creates a result set and then prints some more, then create a result set,
then from the CLIENT's point of view, it receives the first print command
and the procedure's result set together. The client then has to call
SQLMoreResults, then receives the procedure's print commands and the final
result set together.

So, if you want to receive 'PRINT' output in a synchronized way, I suggest
you use SELECT instead.

There are some fine points if you use ODBC 'asynch' calls, but in essence
it's the same deal. Having seen the implementaton of a whack of ODBC
drivers, I'd strongly suggest you not use ODBC asynch calls!

"Andrew Young" <at*******@yaho o.com> wrote in message
news:42******** *************** ***@posting.goo gle.com...
I believe that the messages will only appear once the implicit
transaction or proceedure has ended.

i.e

create procedure ...
print 'process started'
go
exec sp_1
exec sp_2
exec sp_3
...
print 'process ended'
go

It is too bad that you cannot use 'go' in a stored proceedure.

eh****@hotmail. com (James) wrote in message

news:<46******* *************** ****@posting.go ogle.com>...
Hello All,

I have a stored procedure which will act like a main/controller script
which will then invoke more stored procedures (~20). Basically, it
looks something like below:

-- start script
create procedure ...
print 'process started'
exec sp_1
exec sp_2
exec sp_3
...
print 'process ended'
-- end script
Looking at it, after running that procedure, immediately I would expect
the first PRINT statement to be printed but it won't. It seemed
that the print statements would only display the messages after
the whole processing completed.

What's the reason for this sort of behaviour. If so, then we would
not be able to print any progress reporting in our scripts.

Please comment.
Thanks in advance.

Jul 20 '05 #4
James (eh****@hotmail .com) writes:
I have a stored procedure which will act like a main/controller script
which will then invoke more stored procedures (~20). Basically, it
looks something like below:

-- start script
create procedure ...
print 'process started'
exec sp_1
exec sp_2
exec sp_3
...
print 'process ended'
-- end script
Looking at it, after running that procedure, immediately I would expect
the first PRINT statement to be printed but it won't. It seemed
that the print statements would only display the messages after
the whole processing completed.


The message are buffered, this is why don't see them at once. Replace
them with:

RAISERROR('Proc ess started', 0, 1) WITH NOWAIT

and your odds improve. That is, as long as the client library is doing
its job properly, the messages should appear promptly, but I know
some cases where the client incorrectly buffers the message.

As for the RAISERROR, note that the severity is 0. PRINT is just a
short-hand for RAISERROR with level 0...

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
2788
by: Karl Scalet | last post by:
Hi, quite often there is a need to just print out the items of a list. that would be nice, except prt() does not exist, and print is a statement not a function, hence cannot replace prt as of above. I don't like to write d
2
2686
by: John E. Jardine | last post by:
Hi, Problem: Executing 's///' has a side effect on grep null string matching. If line 62, the substitution, is executed the last two values returned by grep and printed on lines 68, 69 are different than the values returned and printed when line 62 is commented out. Line 62 shouldn't have any impact on lines 67,68 & 69. Environment:
17
2394
by: Geoff Cox | last post by:
Hello, I am trying to have 1. web pages in large font 2. web pages with smaller font for printing I am using <link rel="stylesheet" media="print" type="text/css"
21
5740
by: Steel | last post by:
Hi at all, I have a very long html page with many photo. Therefore the best to print this page is to print the some page as PDF. Therefore I maked a PDF file like my page to print best. I'ld want that when the user press the print button in the browser , it print automatically the pdf file and not the html page. To do that I insert at the top of my page: <link media="print" rel="alternate" href="printthepage.pdf"> But it do not work and...
16
11439
by: Neo Geshel | last post by:
I'm helping on a web site, and it's got our knickers in a knot. We're using the same basic CSS files (with mods) and same headers as from our other sites, but the "print preview" won't work correctly on this site. The site is here: http://askdrray.kabis.net (temporary location) The site is being worked on, and only the front page works right now. Expect constant changes. Ignore everything “below the fold”, as the links there...
2
3039
by: Mitul | last post by:
Hello friends, I am getting stuck at a point in my project. I would like to give functionality of print data from site. but there is a problem is that if there are lots of data which takes multiple pages to print then I need to show header that indicates coloum name at top of each page so can any one help me how to do that. the main problem is there are muliple line for each row so I could not
3
3183
by: Terry Hancock | last post by:
I still run into my own ignorance a lot with unicode in Python. Is it possible to define some combination of __repr__, __str__, and/or __unicode__ so that the unicode() wrapper isn't necessary in this statement: <GLOSS: 青い, cl=None, {'wd': u'\u9752\u3044'}> (i.e. can I make it so that the object that print gets is already unicode, so that the label '青い' will print readably?)
69
3228
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of this pep would be to make it impossible to use the name 'print' in a backward compatible manner. Indeed, if a program is to compile in both Python 2.x and Python 3.x, the print function (or the print statement with parentheses) can not use the...
3
3289
by: kimiraikkonen | last post by:
Hi, Here is a very interesting issue, Assume i have picturebox and loaded a image into picturebox, however whenever i want to rotate image using: 'For example 90 degree PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipX) This rotation takes effect on picturebox after i minimize - remaximize form OR after i drag form somewhere outside the screen the re-bring to
0
1000
by: divyaphilip | last post by:
Hi , I have a print button in my aspx file which uses window.print(); to print the page.But it always takes about 30 secs for the print pop up box to appear when the button is clicked the first time.But for all subsequent clicks it takes just a sec.. Is there any way i can have the print pop up box to come up sooner the first time itself?I use c#.net.
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9559
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10529
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9107
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3788
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2964
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.