Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Custom print? Expand / Collapse
Posted Wednesday, March 6, 2013 8:14 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, October 24, 2016 9:51 AM
Points: 551, Visits: 1,099
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.

Post #1427442
Posted Thursday, March 7, 2013 12:03 AM



Group: General Forum Members
Last Login: Yesterday @ 2:36 AM
Points: 7,933, Visits: 14,357
Here's how I usually handle it:

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

SELECT @long_string AS [processing-instruction(long_string)]

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
Post #1427796
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse