Saturday, February 25, 2012

Displaying a field in SQL Server MSE

I have a long text field in a table. Is there a query that I can execute in Mgt. Studio Express that will display the whole of this field. It is too long to easily see in the table view and SELECT <fieldname> from <tablename> only displays part of the field before displaying ellipses (...).

Many thanks,

This depends on what your data is and how you're displaying it. If the data is an XML document then casting it to XML in the select will allow you to click on it and display nicely formatted XML. If it's just text then management studio has a configurable limit on how much it will display. Go to Tools->Options in the menu bar and navigate to Query Results->SQL Server->Results to Grid and set the Non XML data size for results displayed in a grid and Query Results->SQL Server->Results to Text and set the Maximum number of characters displayed in each column for text results.|||

Thanks. This is a VARCHAR(MAX) field. I will try the menu option you recommend.

- A

|||

Hi Roger,

I wanted to know how can we convert (cast) the <Long Text> field into XML.

The query below isn't working !!

SELECT CAST(RateSet AS xml) AS Readable, *
FROM Table

|||

That's the right way to do it. Perhaps if you were to elaborate a little on "isn't working"

This works for me:

create table xmlstuff(txt nvarchar(MAX))

insert into xmlstuff values ('some XML')

select CAST(txt AS xml) from xmlstuff

No comments:

Post a Comment