Problem: How to set a delay
for a query to run.
Blocks the execution of a batch, stored
procedure, or transaction until a specified time or time interval is reached,
or a specified statement modifies or returns at least one row.
This can be useful when there is a
specified time to run the query or for sending alerts at a specified time to
run the query.
Example:
In this
article I am going to show you how wait for delay can be used and a few
examples.
1.
To execute after a
delay for time specified use WAITFOR DELAY ‘hh:mm:ss’
SELECT getdate()
--
ten seconds delay
Select 'delaying
for 10 seconds'
WAITFOR DELAY '00:00:10'
SELECT getdate()
2.
To execute at a particular time use WAITFOR TIME
‘hh:mm’ 24 hr standard
WAITFOR TIME '11:34';
exec sp_who
0 comments:
Post a Comment