Monday, February 7, 2011

Flush the Cache of a Print Statement in SQL Management Studio

If you're using MS Management Studio.  If you want to debug a stored procedure or track the progress of a cursor, you can use print statements.  However, those print statements are cached in a buffer and are only flushed to the Message tab, when the buffer gets to a certain size. Unsure about the specific size.

This blog refers to this issue:
sql server - PRINT statement in T-SQL - Stack Overflow

The solution that worked for me very well using the RAISEERROR command as informational:

declare @print as Varchar(400)
Set @print = 'your message"
RAISERROR (@print,0,1) WITH nowait

Note this will not cause an error, but works exactly like the print statement with a few limitations.



No comments:

Post a Comment