tags:

views:

330

answers:

2

I have a simple query which loops and I want to see the PRINT messages during the execution. The query is something like this:

WHILE 1 = 1
BEGIN
    WAITFOR DELAY '000:00:10'
    PRINT 'here'
END

The PRINT 'here' does not output until I stop the process, however, I want to see it while its running. Is this possible?

+2  A: 

I believe that the prints get buffered, releasing "chunks" as the buffer fills up.

try using raiserror:

http://stackoverflow.com/questions/306945/how-do-i-flush-the-print-buffer-in-tsql

KM
A: 

You can use RAISERROR with serverity 0 and the NOWAIT option

WHILE 1 = 1
BEGIN
    WAITFOR DELAY '000:00:10'
    RAISERROR ('here', 0, 1) WITH NOWAIT
END
Mike Forman