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

PRINT within WHILE loop is not being displayed...

$
0
0
Suppose I have a SQL block like the following. I added a PRINT so that I know that the process is running correctly and it's not in an infinite loop.

Unfortunately, when I execute the script (and this WHILE loop), I notice that the PRINT is not displayed until the script runs completely or the script is stopped (and rollback is complete). But whils it's running, I see nothing on the screen.

Since I'm transferring 4M+ records, I need a way to know that it's running correctly.

Any help is appreciated. Thanks.

While (condition)
BEGIN
    BEGIN TRANSACTION [TRANS1]
        INSERT INTO TABLE
        select * from TABLE2
        where
            myDate > @date1 and
            myDate < @Date2
    COMMIT TRAN [TRANS1];
    PRINT 'INSERTED RECORDS FROM ' + @date + ' ' + @date2
END

Viewing all articles
Browse latest Browse all 23857

Trending Articles



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