rerun query – AumTechHub.Com http://aumtechhub.com Just share it!!! Tue, 23 Nov 2021 01:36:53 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 179596041 How to rerun SQL query after delay? http://aumtechhub.com/how-to-rerun-sql-query-after-delay/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-rerun-sql-query-after-delay Thu, 21 Jan 2021 15:27:28 +0000 http://aumtechhub.com/?p=203 This sample show how to run the same query with delay. It will keep running the same query with 10 second delay and keep re-executing at least 5 times. Good example to when to use this is when you want to check the status on an on going backup.

Select L.NAME DBName,R.percent_complete as [Progress%]
FROM Master.dbo.sysdatabases L Left join sys.dm_exec_requests R on L.DBID=R.Database_ID
WHERE percent_complete > 0
raiserror('',0,1) with nowait
waitfor delay '00:00:10'
GO 15

]]>
203