How to flush the output in a T-SQL script

Very often I need to do the following:

declare @YR int
set @YR = 1993
while (@YR < 2010)
begin
   print getdate()
   ...
   set @YR = @YR + 1
end



This helps me keep track of where the script is.  The problem is,
nothing prints out until the end, when I get all the printings at one
time, which of course does not help much.  So I insert a go
statement.  But then I lose the settings on my variables, such as @YR.

Is there something like "FLUSH" command?
0
Dom
4/12/2010 8:17:25 PM
sqlserver.programming 1873 articles. 0 followers. Follow

3 Replies
2774 Views

Similar Articles

[PageSpeed] 46

Dom wrote:
> Very often I need to do the following:
>
> declare @YR int
> set @YR = 1993
> while (@YR < 2010)
> begin
>    print getdate()
>    ...
>    set @YR = @YR + 1
> end
>
>
>
> This helps me keep track of where the script is.  The problem is,
> nothing prints out until the end, when I get all the printings at one
> time, which of course does not help much.  So I insert a go
> statement.  But then I lose the settings on my variables, such as @YR.
>
> Is there something like "FLUSH" command?

No, but you can do this:
Use the RAISERROR function:

RAISERROR( 'This message will show up right away...',0,1) WITH NOWAIT
-- 
HTH,
Bob Barrows


0
Bob
4/12/2010 8:38:43 PM
On Apr 12, 4:38=A0pm, "Bob Barrows" <reb01...@NOyahoo.SPAMcom> wrote:
> Dom wrote:
> > Very often I need to do the following:
>
> > declare @YR int
> > set @YR =3D 1993
> > while (@YR < 2010)
> > begin
> > =A0 =A0print getdate()
> > =A0 =A0...
> > =A0 =A0set @YR =3D @YR + 1
> > end
>
> > This helps me keep track of where the script is. =A0The problem is,
> > nothing prints out until the end, when I get all the printings at one
> > time, which of course does not help much. =A0So I insert a go
> > statement. =A0But then I lose the settings on my variables, such as @YR=
..
>
> > Is there something like "FLUSH" command?
>
> No, but you can do this:
> Use the RAISERROR function:
>
> RAISERROR( 'This message will show up right away...',0,1) WITH NOWAIT
> --
> HTH,
> Bob Barrows- Hide quoted text -
>
> - Show quoted text -

Does it have any side-effects -- I mean, it raises an error!  If I do
it too often, will the script crash because of an excess of errors?

Dom
0
Dom
4/13/2010 1:59:00 PM
Dom wrote:
> On Apr 12, 4:38 pm, "Bob Barrows" <reb01...@NOyahoo.SPAMcom> wrote:
>> Dom wrote:
>>> Very often I need to do the following:
>>
>>> declare @YR int
>>> set @YR = 1993
>>> while (@YR < 2010)
>>> begin
>>> print getdate()
>>> ...
>>> set @YR = @YR + 1
>>> end
>>
>>> This helps me keep track of where the script is. The problem is,
>>> nothing prints out until the end, when I get all the printings at
>>> one time, which of course does not help much. So I insert a go
>>> statement. But then I lose the settings on my variables, such as
>>> @YR.
>>
>>> Is there something like "FLUSH" command?
>>
>> No, but you can do this:
>> Use the RAISERROR function:
>>
>> RAISERROR( 'This message will show up right away...',0,1) WITH NOWAIT
>> --
>> HTH,
>> Bob Barrows- Hide quoted text -
>>
>> - Show quoted text -
>
> Does it have any side-effects -- I mean, it raises an error!  If I do
> it too often, will the script crash because of an excess of errors?
>
> Dom

Severity codes of 0-10 are informational only and will not crash the
script - this is well-documented in BOL (Books OnLine).
-- 
HTH,
Bob Barrows


0
Bob
4/13/2010 2:35:04 PM
Reply:

Similar Artilces:

ATTN: Ed Crowley (RE:Services won't stop! HELP!)
Here's the exact text of the batch file to stop the services for an offline backup.. It used to work perfectly up to about the last month or so. I've tried changing the order of the services being stopped, but i can't seem to find the "sweet spot". None of the services are set to restart automatically. c:\windows\system32\net stop ntrtscan /Y c:\windows\system32\net stop OfcPfwSvc /Y c:\windows\system32\net stop tmlisten /Y c:\windows\system32\net stop w3svc /Y c:\windows\system32\net stop SMTPSVC /Y c:\windows\system32\net stop HTTPFilter /Y c:\windows\system32\n...

post-backup script for tape abckup
I need to create a post-backup script (to tape) to mark a tape "ready for off-site" and if possible, eject or move it to "impot/export" zone. Please let me know how to get it done. Thanks Bill Marking a tape ready for off-site is not possible, if you are looking for ejecting the tape from a library, please take a look a the Unlock-DPMLibraryIEPort cmdlet at: http://technet.microsoft.com/en-us/library/bb809145.aspx Thanks, Praveen D [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. "Bill N&q...

How do I join a querry field to a table in a form's SQL
From another post, where I have recieved some help, I am now wanting a little more. I am told that 'In the main Shipping_Control form source SQL you have to join the qryPartValue to tblShipping_Control.' This is the SQL from the qryPartValues SELECT Shipping_Control.DescriptionOfCargo, Shipping_Control.CargoQty, tblValues.Value, ([Shipping_Control].[CargoQty]*[tblValues].[Value]) AS CommercialValue, Shipping_Control.ShippingDate, Shipping_Control.ShipTo, Shipping_Control.ShipFrom, Shipping_Control.CollectionNoteNo, Shipping_Control.PackingListNo, Shipping_Control.Sh...

Please help
Problem: I can't get my Exchange 2000 migration wizard to communicate with an Exchange 5.5 server. Environment: On an "inherited" network, I have a newly built (by me) Win2K SP4 server running AD (only server in AD), and an old Exchange 5.5 server on a separate NT4 SP6a domain (PDC) - on the same subnet. I have removed TCPIP and have reinstalled SPs for Exch and NT4. I have 2-way trusts set up between the domains, and they can browse each other's files. DNS has been set up, and I have forward zones for both of the domains. There is no internal DNS on the NT4 domain....

How to enter output range for Descriptive statistice #2
Hi I'm trying to get Descriptive statistics summary, and couldn't enter output range. what is the formate? Hi, You just need to click on (or enter) the upper left cell where you want the data to appear, usually to the right of, or below, your data. Dave url:http://www.ureader.com/msg/10296114.aspx ...

Xpath / XPathExpression equivalent of SQL's "Top" function
Is there one? Also in either xpath or XPathExpression whats the best way to get the full xpath of a node. As i am using xpath query of (//books/.......) So I would like to see what is before the /book tag? > Is there one? Yes you can do /books/book[position()<6] That will select the first 5 book elements in the books node. > As i am using xpath query of (//books/.......) > > So I would like to see what is before the /book tag? Hmm you can get the parent node once you get the child I guess. -- Victor Hadianto http://www.synop.com/Products/SauceReader/ "ree32"...

Database Queries with database views, that base on many database t
I created 2 database views. Each of them uses 256 database tables. From every database table only one column is used in the select list of the view. Every database table has one column which is used for the join. Each database table has 5 rows. The database tables have not any foreign keys and indexes. Both views works fine. When I use the database views in a query like this: SELECT v1.*, v2.* FROM v1, v2 WHERE v1.id=v2.id I should get 5 rows with 512 columns in the resultset. But I get the following error from the SQL-Server (after about 5 minutes): Msg 8621, Level 17, State 2...

OsCommerce - Easy Populate Script
I am having a problem I just had this Easy Populace script installed for OsCommerce, I am having problems getting the correct format in order to mass upload all of the products I have in my database files from the companies that supply me. Below is all the information. I need to be able to convert a CSV file, to a TXT file, in the EXACT same format as below. If some one could please post a walk through on how to achieve this I would highly appreciate it! The Easy Populate Script - http://www.oscommerce.com/community/contributions,500 The .txt file showing the Format I need. http://pricetri...

Can't create address labels with an image / graphic
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I am using MS Word for MAC - version 2008 and can't for the life of me create a page of labels with a graphic. <br><br>The old 2004 version worked beautifully. I could pull up a blank template (ex. 5160), group the graphic and text box in one cell, then select &quot;Tools -> Labels&quot; and that would create an entire page of that design. I got the 08 version, and now I can't do a thing. That process just gets me another blank template. <br><br>Not sure how many people...

another applic. did't shut down properly messed up outlook.pst
I was setting up companion link to sync goldmine calender. It did not work so I uninstalled companion link and tryed to reenter outlook. Now I get this error message: Unable to display folder. Another application closed while using your personal folders file....outlook.pst. How do I fix the error and use my outlook. Billy Calhoun;117725 Wrote: > I was setting up companion link to sync goldmine calender. It did not > work > so I uninstalled companion link and tryed to reenter outlook. Now I > get this > error message: Unable to display folder. Another app...

Why doesn't my original message text show in the reply message?
When I send out e-mails, sometimes the reply back to me does not include my original text. Why? I know they are just hitting the reply button because the Re line has "exactly" what I originally typed. This has happened on several occasions. There is an option in Outlook and Outlook Express to include the original message in a reply. If they have that option disabled, then when they reply to you, the original message will be removed from the email. In order to enable or disable this option in Outlook 2003 (I believe 2007 and Outlook Express are similar) please do...

Couldn't find my .aspx file
Hi There, I have developed a .aspx page in sharepoint designer which has link like this:http://ServerName:8080/AccessForms/Entry_Form.aspx I have access to server(ServerName) but I am not able to find this file (Entry_Form.aspx) anywhere on 'ServerName'. I have gone through each and every directory on server but couldn't find it. Your help will be highly appreciated. Submitted via EggHeadCafe - Software Developer Portal of Choice No-SOAP, No-Webservice WSE Xml Signature http://www.eggheadcafe.com/tutorials/aspnet/fb38417b-77c0-4f9b-901a-bc2341bc3a08/nosoap-nowebser...

Can't View Downloaded Items to Review
In my transaction view, after connecting to my Bank, I usually have items that show up in my transactions list based on how many items were downloaded. I have 8 Items for Review, but they do not show up in the transaction list?!?!?! Try the following article: http://support.microsoft.com/default.aspx?scid=kb;en-us;316900&Product=mny "Dalton" <geoff@2bones.com> wrote in message news:e6EFv8vgDHA.520@tk2msftngp13.phx.gbl... > In my transaction view, after connecting to my Bank, I usually have items > that show up in my transactions list based on how many items were...

Can't insert Page Break (Continuous)
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel When I try to insert a CONTINUOUS page break, it starts the section on the NEXT page. Right now, my doc has only one section. I am trying to isolate one part in the middle of the doc as a separate section to change some settings. This problem does not occur if I try to perform the same task a few paragraphs up. ETA: My doc only has one section plus footers. OK, you're going to have to be more exact about what you're attempting to do as well as more specific about the structure of your document content as well a...

LoadLibrary Failing when it shouldn't.
I have an application in which I have an MFC (statically linked) EXE and a non-MFC DLL. Up until yesterday, I was having no problems and everything was working just fine. Now this morning, I'm getting a strange error. In my EXE I use LoadLibrary to load my non-MFC DLL and to load some other functions from kernel.dll. Loading kernel.dll works fine, no problem at all. However, the LoadLibrary calls to MY dll fail with a "The specified module could not be found" error. Mr Obvious says to check the path, which I have done over and over and over. Even if I hardcode the fully qualifi...

Can't create file: FAX.TIF
I keep getting this error message when I try to open faxes that come down over our server. Here is the entire message. Can't create file: FAX.TIF. Right click the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions for the folder. I have checked the properties for the Inbox and for the Office Document Imaging and all of that is fine. We were able to open faxes fine, then one day a Smiley bar appeared in Outlook and then we were not able to open the faxes anymore. Also, I have removed Outlook and reinstalled. I hav...

Can't bring up web pages
Hello, A couple weeks ago, a particular workstation couldn't bring up webpages with IE v7. Then it cleared up on its own. Yesterday the same workstation had the problem again as well as another workstation on the lan. I don't know if this is related, but my workstation cannot access the main server even though the drives are successfully mapped and the antivirus won't update. Has anyone seen this type of problem? Could it be a known virus? Thanks for any help and God Bless, Mark A. Sam Internet Options... Connections Tab.... Lan Settings Button.... ...

Can't sell or transfer out all of my investment
In Money 2002, I have 250 shares of 'stock'. If I attempt to sell or transfer out more than 150 shares, the program reports that my account balance would go negative at some point, and refuses the transaction. 150 shares, no problem. After selling 150 shares, if you go back into the portfolio, there are still 100 shares remaining. Try to move them at all, and you get that same problem. I've been scratching my head over this one for a while. This is definitely a bug. I have even tried deleting all transactions related to that investment and then re- entering them. No...

CRM 3.0 Workflow don't work
each time when i apply rule to an opportunity.I got a workflow error blow: Condition {1D992E3C-EC2E-DC11-B318-005056C00008} failed in step {1B992E3C-EC2E-DC11-B318-005056C00008} of process instance {F4982E3C-EC2E-DC11-B318-005056C00008}. Please view the paused rule in the Microsoft.Crm.Workflow.Monitor for more information about the failure. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. When I try to pause and resume the workflow in workflow monitor.The workflow can keep going. what is the problem on my server? On Jul 10, 10:20 am, &...

SSIS independent of SQL Server 2005?
Hello! Is it possible to purchase only SSIS 2005 and not the SQL Server 2005 Standard/Enterprise Edition? Or SSIS only comes with SQL Server 2005 Standard/Enterprise Edition? Please clarify my doubt. Thanks in advance Hi BID (Business Intelligence Development Studio) which comes with SQL Server 2005 is part/short version of VS2005... You can have VS2005 to use SSIS as well, however EXPRESS edition does not support SSIS as I recall, I mean you are able to launcg .dtsx files but not to develop... You have can Developer Edition ~50$ and SSIS "MandarPatki" ...

Can't receive e-mail
Hi there We are using Windows Mail to read e-mail, but have now got a problem. When we attempt to read e-mail we get the following error message: - An unknown error has occurred. Account: 'pop3.blueyonder.co.uk', Server: 'pop3.blueyonder.co.uk', Protocol: POP3, Port: 110, Secure(SSL): No, Error Number: 0x80004005 We've re-set the Windows Mail settings, but still get this message. Can anyone help? Graham PS - We can send e-mail!!!!! The 0x80004005 error often indicates corruption of the mailbox on the server. In your browser go to https://webmai...

switching users
I have a computer that on which I needed to create a new user profile. I set up Outlook on the new profile with the same email account, but it gives me an error when retrieveing mail. I have Outlook 2000. I have checked the account settings several times. I can retrieve the email if i set up the account on another computer. Any thoughts? Thanks, Peter peter wrote: > I have a computer that on which I needed to create a new user profile. > I set up Outlook on the new profile with the same email account, but > it gives me an error when retrieveing mail. I have Outlook 2000. I > ha...

Help! Can't Import Quicken 2001 Deluxe Data into MS Money 2004 Standard
Hello, I have a relatively new Compaq Desktop (2.5 GHz Celeron with 512 MB RAM). I have a Viewsonic Pocket PC and I wanted to use it to track my financial data so I purchased Money 2004 Standard. I tried several times to convert my Qucken Data (it's a big file--I've been using Quicken since 1995). My Quicken program is Quicken 2001 Deluxe. Anyway, the MS Money program started to convert and after a few minutes said: "Your Quicken file could not be converted. Money could not convert your Quicken file. You might have run out of disk space or system memory. Try closing othe...

Can't Reply messages................HELP
I cant seem to reply messages both in outlook 2003 and outlook 2007. every time i reply to a sender not in my address book the senders name appears on the "to" field but not the addresses. How do i fix this..... Help What happens when you send? The address is not shown if it is not part of the display name. When you right click the address and choose Outlook Properties, do you see their address then? -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://w...

SQL Server replication
Hi, I have a client that has offices in CPT & JHB. They plan on doing transactions on a sql server in JHB on a Dynamics company e.g XYZ and then replicating this to the same company (XYZ) on a different server in CPT. The people in Capetown will never enter transactions to the XYZ company ion the CPT server, but purely need to see the data entered by the staff in JHB for month end reporting. I want to use sql replication to achieve. I assume the steps would be: 1) Create a local publication from the database in JHB (and scheudle it per week) 2) Create a local subscription from th...