SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)


By Timothy A Wiseman,

This very simple procedure is designed to overcome the limitation in the SQL print command that causes it to truncate strings longer than 8000 characters.

It will print the text passed to it in substrings smaller than 8000 characters. If there are carriage returns (CRs) in the text, it will break up the substrings at the carriage returns and the printed version will exactly reflect the string passed.

If there are insufficient CRs in the text, it will print it out in blocks of 8000 characters with an extra carriage return at that point.

If it is passed a null value, it will do virtually nothing.

I developed a need to display very lengthy strings while trying to debug a script that generated a very long dynamic SQL section. When I did not instantly find a script to do this on SQLServerCentral.com I decided it would be faster to write one myself than search the broader internet.

Total article views: 1417 | Views in the last 30 days: 4
Related Articles

Carriage return in xp_sendmail

Sent email does not include carriage return


Tame Those Strings - Finding Carriage Returns

Expanding on his series of string manipulation in T-SQL, Steve Jones takes a look at how you go abou...


Hidden carriage returns

Why don't carriage returns show up in a text field?


Need to merge multiple rows into one with carriage return

Need to merge multiple rows into one with carriage return


Carriage return in txt file

Inserting a carriage return in a txt file via stored procedure

string manipulation