Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

WAITFOR DELAY: How can I continue to delay and excute until process is complete?

$
0
0

Hello my friends:

Is it possible to run a select statement an wait, then run again until the table has no data?

The following is an example code:

BEGIN
IF (SELECT COUNT(*) FROM MySchema.MyTable) > 1
BEGIN
    WAITFOR DELAY '00:00:5';
    SELECT COUNT(*) FROM MySchema.MyTable;
    END
END

I want to repeat the code above with the delay until the table count is zero.

Is this possible?

Thanks!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>