Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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)

LongPrint

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: 1198 | Views in the last 30 days: 15
 
Related Articles
FORUM

Carriage return in xp_sendmail

Sent email does not include carriage return

ARTICLE

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...

FORUM

Hidden carriage returns

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

FORUM

Need to merge multiple rows into one with carriage return

Need to merge multiple rows into one with carriage return

FORUM

Carriage return in txt file

Inserting a carriage return in a txt file via stored procedure

Tags
print    
string manipulation    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones