Prev: Return 0 (zero) when null
Next: ActiveMQ uplock preventing transaction log backup and truncation.
From: Dom on 12 Apr 2010 16:17 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 12 Apr 2010 16:38 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 13 Apr 2010 09:59 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 13 Apr 2010 10:35 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
|
Pages: 1 Prev: Return 0 (zero) when null Next: ActiveMQ uplock preventing transaction log backup and truncation. |