我使用 RAISERROR 从存储过程中生成进度输出而不是使用 PRINT,以避免 PRINT 对输出进行缓冲。现在我发现 RAISERROR 将在 500 次打印后开始缓冲。有没有办法解决这种行为? 下面的查询将显示我的观点:
DECLARE @i INT = 0
WHILE @i < 50000
BEGIN
SET @i = @i + 1
RAISERROR('%i prints', 0,1 , @i) with nowait;
IF @i > 500 --<--after 500 prints RAISERROR starts buffering 50 prints before flushing.
WAITFOR DELAY '00:00:00.050';
END;
最佳答案
埃兰·萨默斯坎 reported :
However, beware that Mgmt Studio starts buffering also NOWAIT messages after 500 messages.
This does not happen with the old Query Analyzer that comes with SQL 2000
如果您没有可用的 QA,也许您可以尝试使用 SQLCMD.EXE 而不是 SSMS。可能500以后就不做缓冲了。
关于sql - RAISERROR WITH NOWAIT 缓冲的解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25746625/