• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

timer SQL

following is my code

declare @testing varchar(255)
declare @testing2 varchar(255)



set @testing = '4'
set @testing2 = '5'
print @testing
exec master..xp_cmdshell 'net send agmpimo258 ayam'

      

if @testing = '4'
      runCmds:

            WAITFOR DELAY '00:00:04'  --pauses for 1 minute
            print @testing2


well above is the example of the code.. i am trying to delay the program when the condition meet the if statement but when i write in that way the whole program will get delay eventhough the condition is not full filled.. please advise....thanx very much

 
0
mingfattt
Asked:
mingfattt
  • 2
1 Solution
 
Thandava VallepalliCommented:
try this

declare @testing varchar(255)
declare @testing2 varchar(255)



set @testing = '4'
set @testing2 = '5'
print @testing
exec master..xp_cmdshell 'net send agmpimo258 ayam'

     

if @testing = '4'
begin
     runCmds:

          WAITFOR DELAY '00:00:04'  --pauses for 1 minute
          print @testing2
end
0
 
Thandava VallepalliCommented:
you forgot the begin end statmenets...

itsvtk
0
 
ShogunWadeCommented:
concur with itsvictk

IF statements apply to the next statement or block of statement following it.   thus multiple statements must be made into a block of statements by wrapping in BEGIN and END
0
 
mingfatttAuthor Commented:
well... i realize that the code is work but here what i mean.... the message for the print @testing is coming out after four seconds and together with the print @testing2 well let say my case is i have the bundle of file... now i want to detect whether the file is exist and if not the stored procedure will delay for certain particular of time... is this work... please clarity fhanx and appreciated...

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now