Quick one today:
Occassionally, we need to introduce forced wait or delays when running some T-Sql statements. There is an easy way to accomplish it.
There are a couple of ways to implement this.
- Relative wait : Introduce wait for a few seconds/minutes/hours before running the next command
- Absolute wait : Wait until a particular time, then run the next command. Ex: Run next command at 10:30 pM
-- -- Relative Wait: Wait for 10 minutes before running backup -- USE master GO WAITFOR DELAY '00:10:00' -- wait for 10 minutes before running backup BACKUP DATABASE master TO DISK = N'S:\master.bak' GO -- -- Absolute Wait : Do something at 10:30 PM -- USE master GO WAITFOR TIME '00:22:30' -- run back up at 10:30 PM BACKUP DATABASE master TO DISK = N'S:\master.bak' GO
Hope this helps,
_Sqltimes
Leave a comment