Specifies a specific time, a time interval, or an event for the execution of a statement block, stored procedure, or transaction.
waitfor {delay time | time time | errorexit | processexit | mirrorexit}
begin waitfor time "14:20" insert chess (next_move) values ('Q-KR5') execute sendmail 'judy' end
declare @var char (8) select @var = "00:00:10" begin waitfor delay @var print "Ten seconds have passed. Your time is up." end
begin waitfor errorexit print "Process exited abnormally!" end
After issuing the waitfor command, you cannot use your connection to the SAP ASE server until the time or event that you specified occurs.
You can use waitfor errorexit with a procedure that kills the abnormally terminated process, to free system resources that would otherwise be taken up by an infected process.
To find out which process terminated, check the sysprocesses table with sp_who.
The time you specify with waitfor time or waitfor delay can include hours, minutes, and seconds. Use the format “hh:mi:ss”, as described in Date and Time Datatypes in Reference Manual: Building Blocks.
waitfor time "16:23"
waitfor delay "01:30"
Changes in system time (such as setting the clock back for Daylight Savings Time) can delay the waitfor command.
You can use waitfor mirrorexit within a DB-Library program to notify users when there is a mirror failure.
Date and Time Datatypes in Reference Manual: Building Blocks
sp_who in Reference Manual: Procedures
ANSI SQL – Compliance level: Transact-SQL extension.
No permission is required to use waitfor.