How do I flush the PRINT buffer in TSQL?

后端 未结 5 1676
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 16:04

I have a very long-running stored procedure in SQL Server 2005 that I\'m trying to debug, and I\'m using the \'print\' command to do it. The problem is, I\'m only getting th

5条回答
  •  鱼传尺愫
    2020-11-29 16:45

    Another better option is to not depend on PRINT or RAISERROR and just load your "print" statements into a ##Temp table in TempDB or a permanent table in your database which will give you visibility to the data immediately via a SELECT statement from another window. This works the best for me. Using a permanent table then also serves as a log to what happened in the past. The print statements are handy for errors, but using the log table you can also determine the exact point of failure based on the last logged value for that particular execution (assuming you track the overall execution start time in your log table.)

提交回复
热议问题