SQL Server: PRINT output does not appear immediately

In SQL Server 2005 Management Studio, it seems that the output of the PRINT statements is not displayed immediately: if I have a PRINT statement followed by a long statement, the PRINT output does not appear until the next statement.

Is there a way to reset the output earlier? I am running several upgrade scripts that require age, and I would like to know how far the script is going (so I know whether to wait a few minutes and then run the next one, or go for lunch).

+42
sql-server
Dec 08 '08 at 12:24
source share
2 answers

No. They will be returned only when the transaction is completed, when other records or the completion of the statement are returned ( go terminator of the statement in the SQL package). You can use raiserror at fatal error levels (0-18) to get this kind of immediate feedback. For example:

 RAISERROR ('Foo', 10, 1) WITH NOWAIT 
+69
Dec 08 '08 at 12:26
source share

This worked for me by simply placing the GO command after the print commands, for example

 print 'test' print 'test' go 

In general, my conclusion is the following: the output of the mssql script of execution executed in the SMS-graphic interface or with sqlcmd.exe is cleared in the file, stdoutput, gui-window in the first GO statement or until the end of the script.

Flushing inside a stored procedure works differently since you cannot place GO inside.

Link: tsql go instruction

-2
May 23 '15 at 17:19
source share



All Articles