Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

[HELP] FOR XML Expand / Collapse
Author
Message
Posted Monday, July 22, 2013 4:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 9, 2013 1:31 AM
Points: 8, Visits: 29
Hi All,

I need use SQL (for xml) to write in this customize format of XML as below:


<track_n_trace tranid="1234" ordernum="ABC123">
<current_location>MY</current_location>
<status code="OK" reason_code="FINE">
<remark>KUU1234</remark>
</status>
<consignment_number>A5555</consignment_number>
<total_shipped overall_qty="0" box_qty="0"/>
</track_n_trace>
Post #1475922
Posted Monday, July 22, 2013 7:41 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:28 AM
Points: 1,828, Visits: 1,363
Maybe this will help.

SELECT 1234 AS '@TranID', 'ABC123' AS '@OrderNum', 
'MY' AS 'Current_Location',
(
SELECT 'OK' AS '@Code', 'FINE' AS '@Reason_Code', 'KUU1234' AS 'Remark'
FOR XML PATH('Status'), TYPE
) AS 'node()',
'A5555' AS 'Consignment_Number',
(
SELECT '0' AS '@Consignment_Number', '0' AS '@Box_Qty'
FOR XML PATH('Total_Shipped'), TYPE
) AS 'node()'
FOR XML PATH('Track_N_Trace')






Everything is awesome!
Post #1476018
Posted Thursday, August 1, 2013 8:09 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 9, 2013 1:31 AM
Points: 8, Visits: 29
Dana Medley (7/22/2013)
Maybe this will help.

SELECT 1234 AS '@TranID', 'ABC123' AS '@OrderNum', 
'MY' AS 'Current_Location',
(
SELECT 'OK' AS '@Code', 'FINE' AS '@Reason_Code', 'KUU1234' AS 'Remark'
FOR XML PATH('Status'), TYPE
) AS 'node()',
'A5555' AS 'Consignment_Number',
(
SELECT '0' AS '@Consignment_Number', '0' AS '@Box_Qty'
FOR XML PATH('Total_Shipped'), TYPE
) AS 'node()'
FOR XML PATH('Track_N_Trace')




Hi,

Thanks your help. It really helping me .. :)
Post #1480230
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse