question

palum avatar image
palum asked

XML Format using the xml datatype in sql server2008

I am trying to generate a format in xml but the format changes in XML. I know that can be done using varchar(max). As I am using methods in xml and methods cannot be called on varchar.So i have to stick with xml datatype. Can anyone help me to generate the file in the below format in XML? DECLARE @HoldFile AS XML SELECT @HoldFile=CAST(' ' AS XML) SELECT @HoldFile The submission tag changes to I want this tag to be
tsqlxml
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

JD avatar image JD commented ·
...but the format changes in XML... sorry, I don't understand your question, what is changed..?
1 Like 1 ·
Scot Hauder avatar image Scot Hauder commented ·
the code alphabetizes the attributes, your code that consumes this should not care
0 Likes 0 ·

1 Answer

·
Micke avatar image
Micke answered
From [Limitations of the xml Data Type][1]: > The order of attributes in an XML > instance is not preserved. When you > query the XML instance stored in the > xml type column, the order of > attributes in the resulting XML may be > different from the original XML > instance. So if you put your XML in a XML data type there is no guarantees about the order of attributes. [1]: http://technet.microsoft.com/en-us/library/ms187107%28SQL.90%29.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.