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


Custom print?


Custom print?

Author
Message
Erin Ramsay
Erin Ramsay
SSC Eights!
SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)SSC Eights! (815 reputation)

Group: General Forum Members
Points: 815 Visits: 1099
Has anyone built or seen a custom Print function for SQL? I'm running into the 4000 character limitation and before I go ahead and build one of my own I was wondering if anyone already had one. Basically the problem I'm running into is that my nvarchar(max) is way over 4000 characters and I need to print it in pieces, extracting 4000 character chunks from it each time.

Thoughts?
Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14835 Visits: 14396
Here's how I usually handle it:

DECLARE @long_string NVARCHAR(MAX) = N'Hello world!';

SELECT @long_string AS [processing-instruction(long_string)]
FOR XML PATH(''),
TYPE;



It outputs a clickable XML cell when in the SSMS with Grid Output turned on and when you click on it you see the entire text, untruncated, as an XML fragment:

<?long_string Hello world!?>




edit: quote XML so angle-brackets are not escaped

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search