Deborah Melkin does not take kindly to bugs:
I often find that I have to write complicated stored procedures where I need to check things as I go along. My go-to for using this snippet is when I write stored procedures that use dynamic SQL. You’d be surprised (or not) at how often I have had to do this over the years. There’s been functionality where the user gets to choose the columns being used, rewriting ORM data layer “catch-all” queries to improve performance, and cross database queries where the name of the database may not be the standard name (think development and QA databases living on the same SQL instance.)
Click through for an example of where the
@Debug parameter pays off. My recollection was that, for really long NVARCHAR(MAX) strings, running
PRINT by itself might cut off the code after ~4000 characters, but that could be a historical recollection.