Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to append an xml file using sql query

Author  Topic 

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2012-04-10 : 10:01:40
Hi All,

I have generated an xml file using xml explicit and my output appears as below.

<RequestStatus>
<Authentication id="57985775">AYUPXNHD</Authentication>
<ForwardMessage id="187384820" />
</RequestStatus>

i want to append on the top of my xml with '<?xml version="1.0"?>' and overall it should look like

<?xml version="1.0"?>
<RequestStatus>
<Authentication id="57985775">AYUPXNHD</Authentication>
<ForwardMessage id="187384820" />
</RequestStatus>

please find my query below and help me on the same

SELECT * FROM(

SELECT 1 AS Tag,
NULL AS Parent,
NULL AS 'RequestStatus!1!' ,
NULL AS 'Authentication!2!id' ,
NULL AS 'Authentication!2!',
NULL AS 'ForwardMessage!3!id',
NULL AS 'ForwardMessage!3!'
UNION ALL
SELECT TOP 1
2 AS tag,
1 AS parent,
NULL,
ControlStationID,
[Password],
NULL ,
NULL
FROM SW_ControlStations WITH (NOLOCK)
UNION ALL
SELECT
3 AS TAG,
1 AS PARENT,
NUll,
NULL,
NUll,
ForwardMessageID AS ReturnMessageID,
NULL
FROM SW_MessagesSubmit )A
FOR XML EXPLICIT )

rams

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-10 : 15:20:56
see

http://msdn.microsoft.com/en-us/library/ms177400.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -