Monday, June 30, 2008

dealy in sql or wait in sql query

In many application or process we required dealy

there is dealy in sql server
call WAITFOR

select '1'
WAITFOR DELAY '00:00:30'

above query run and wait 30 sec for output

select '2'
WAITFOR Time '15:00'


above query run and wait for 3:00pm for output


WAITFOR gives out put after end of process if you want out put after each wait then use code as follows

select getdate()
WAITFOR DELAY '00:00:30'
Go
select getdate()
WAITFOR DELAY '00:00:30'
Go
select getdate()
Go

alternate logic for delay is while loop but its not accurate
it gives differnt interval on different configuration server.

No comments: