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?
@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;