I'm trying to use WAITFOR DELAY statement in a while loop, but it dose not work. I wrote the following code in query analyzer:
select dbid, count(dbid) as count
group by dbid
waitfor delay '00:02:00'
Is there anything wrong? Please help me.
I want the loop to run indefinitely and perform the SQL statements periodically. I can get the WAITFOR DELAY to work fine as long as it runs only once but it does not work in the loop.
Nothing is printed and if I cancel the query it simply reports that user canceled the query and I'm working with SQL 2005.
Nothing is printed, because the data returned has not yet hit the network packet size (it is a VERY bad idea to change that for this purpose, by the way). If you redirect the output to a table, you will see the rows generated there.