SQL Server: PRINT output doesn't appear immediately

Sql Server

Sql Server Problem Overview


In SQL Server 2005 Management Studio, it appears that the output of PRINT statements doesn't appear immediately: If I have a PRINT statement followed by a long-running statement, the PRINT output doesn't appear until after the following statement.

Is there any way to flush the output earlier? I'm running some upgrade scripts that take an age to complete, and I'd like to know how far along the script is (so I know whether to wait a few minutes and then start the next one, or whether to go to lunch).

Sql Server Solutions


Solution 1 - Sql Server

No. Output of PRINT statements will only be returned when a transaction is committed, when other record sets are returned or a statement is completed (go statement terminator in a SQL batch). You can use raiserror at non-fatal error levels (0-18) to get immediate feedback of this sort. For example:

RAISERROR ('Foo', 10, 1) WITH NOWAIT

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRoger LipscombeView Question on Stackoverflow
Solution 1 - Sql ServerConcernedOfTunbridgeWellsView Answer on Stackoverflow