rac.coons (6/28/2013)
Here's a very quick and easy way to display all characters that I did not see here.select convert(xml,'<txt>' + @txt + '</txt>')
In SSMS, it returns a link that opens a new tab with all of the text.
I was going to suggest nearly the same thing :-). The only thing I would change is that adding in the XML tags for the root node is not necessary.
I would think that the easiest way to see up to 2 MB of text that also happens to work just as well in a query as it does for printing a single variable is:
SELECT CONVERT(XML, @Variable)
OR
SELECT Field1, Field2, CONVERT(XML, Field3) AS [Field3]
FROM Schema.Table
This is a little more flexible, and straight-forward, than using FOR XML as that might not be desirable when debugging a query.
Take care,
Solomon...
Edit:
Correction on the 2 MB limit. I thought it was the max but I just checked again and it isn't. If you go to:
Tools -> Options... -> Query Results -> SQL Server -> Results to Grid
you will see at the bottom of the right side, in the "Maximum Characters Retrieved" section, a drop-down for "XML data:" that has the following options:
1 MB
2 MB (default)
5 MB
Unlimited
SQL# — https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
Sql Quantum Lift — https://SqlQuantumLift.com/ ( company )
Sql Quantum Leap — https://SqlQuantumLeap.com/ ( blog )
Info sites — Collations • Module Signing • SQLCLR