From: Dom on
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?
From: Bob Barrows on
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


From: Dom on
On Apr 12, 4:38 pm, "Bob Barrows" <reb01...(a)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
From: Bob Barrows on
Dom wrote:
> On Apr 12, 4:38 pm, "Bob Barrows" <reb01...(a)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