question

palum avatar image
palum asked

gen a file

I am trying to cast somethings in xml like DECLARE @abc as XML SELECT @abc =CAST(' 01-23-2011 23:01 ME 1.0 1 1 PALUM 123456 online ' AS XML) SELECT @abc AS XML but when the xml file is generated it formats it differently something like 01-23-2011 23:01 ME 1.0 1 1 PALUM 123456 online If u see the first 2 lines in the header its changed how can i keep those two lines while generating and xml file?
t-sql
10 |1200

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

1 Answer

·
Oleg avatar image
Oleg answered
@palum There is no xml file in your question, so it is difficult to figure out what are you asking. All you have is a string which you for some reason cast as xml before selecting it. This does strip the xml declaration part from the file because variables of xml datatype do not need the declaration part (equivalent of OmitXmlDeclaration = true property value of the xml writers in .NET languages). If you need to preserve the declaration then don't cast your results as xml, but instead declare @abc as varchar(max); select @abc = 'your_xml_goes_here'; select @abc;
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.