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 the messages back from SQL Server at the very end of my sproc – I'd like to be able to flush the message buffer and see these messages immediately during the sproc's runtime, rather than at the very end.
Sql-server – How to flush the PRINT buffer in TSQL
printingsql servertsql
Related Topic
- Sql – How to return only the Date from a SQL Server DateTime datatype
- Sql-server – How to check if a column exists in a SQL Server table
- Sql-server – How to get list of all tables in a database using TSQL
- Python – How to flush the output of the print function
- Java – What’s the simplest way to print a Java array
- SQL Server – transactions roll back on error
- Sql – How to UPDATE from a SELECT in SQL Server
- Python – How to print to stderr in Python
Best Answer
Use the
RAISERROR
function:You shouldn't completely replace all your prints with raiserror. If you have a loop or large cursor somewhere just do it once or twice per iteration or even just every several iterations.
Also: I first learned about RAISERROR at this link, which I now consider the definitive source on SQL Server Error handling and definitely worth a read:
http://www.sommarskog.se/error-handling-I.html