KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've been battling with this one for a few days now, I'm looking to automate an XML output with the below syntax SELECT ( SELECT CONVERT(VARCHAR(10),GETDATE(),103) FOR XML PATH('DataVersion'), TYPE ), ( SELECT CoNum, CoName, CONVERT(VARCHAR(10),AccountToDate,103) 'DLA', LAFileNet FROM @XMLOutput FOR XML PATH('Company'), TYPE ) FOR XML PATH(''), ROOT('Companies') Which creates the below output <Companies> <DataVersion>15/11/2010</DataVersion> <Company> <CoNum>111</CoNum> <CoName>ABCLmt</CoName> <DLA>12/12/2010</DLA> <LAFileNet>1234</LAFileNet> </Company> <Company> <CoNum>222</CoNum> <CoName>DEFLmt</CoName> <DLA>12/12/2007</DLA> <LAFileNet>5678</LAFileNet> </Company> </Companies> What I'm struggling with is how to add the XML declaration <?xml version="1.0" encoding="ISO-8859-1" ?> to the top of the output?? Update 1: Would I be correct in thinking I need to create a XML schema in SQL server to define the xsl:output. Then assign the output to that schema? Update 2: Have since found these links http://forums.asp.net/t/1455808.aspx -- Check out comment from Jian Kang. Also http://www.devnewsgroups.net/group/microsoft.public.sqlserver.xml/topic60022.aspx
Tags (comma-separated)
Save Edits
Cancel