1

I have an xml doc (size: 3.59 mb) with 3765815 total characters in it. My sql server 2008 database table has a column with xml data type. When I try to insert this xml into the column it seems to truncate it.

I thought xml data type can handle 2GB of data. Is this a correct understanding or am i missing something?

Thanks

Here is the query i am using

declare printxml nvarchar(max) 

select printxml=cast(inputxml as varchar(max))
from TableA
where SomeKey='<some key>'

print printxml
3
  • How many bytes/characters is it truncated to? Commented Jun 23, 2011 at 0:58
  • yes. i am trying to view in management studio. it truncates to 4002 characters. When i try to open the xml text in the column in management studio it says xml not well formed. I did declare a variable and print the variable and it was truncated to 4002 characters. Commented Jun 23, 2011 at 1:01
  • 2
    Take a look here: support.microsoft.com/kb/263574 Commented Jun 23, 2011 at 1:05

1 Answer 1

4

Select the data directly instead of printing it to the messages window:

SELECT
    inputxml
    FROM TableA
    WHERE SomeKey = '<somekey>'

The caveat is that you have to set up Management Studio to be able to return all the data to the window. You do that using the following option (the default setting is 2MB):

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.