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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Table to XML

Author  Topic 

orenshto
Starting Member

3 Posts

Posted - 2015-06-22 : 07:08:57
Hey,
I've got the following table structure:
UDI description VALUE Units client_id
10 Customer id 10247 CID 10247
20 Customer Name ABC CUST_NAME 10247
10 Customer id 12261 CID 12261
20 Customer Name DEF CUST_NAME 12261

two rows for each customer ID, each customer has 2 UDI (10, 20).
I would like to have a query which will generate the following:
<Customer>
<Datum UDI="10" Description="Customer ID" Value="10247" Units="CID" />
<Datum UDI="20" Description="Customer Name" Value="ABC" Units="CUST_NAME" />
</Customer>
<Customer>
<Datum UDI="10" Description="Customer ID" Value="12261" Units="CID" />
<Datum UDI="20" Description="Customer Name" Value="DEF" Units="CUST_NAME" />
</Customer>
each client ID will have 2 rows and every client ID will generate new customer.
   

- Advertisement -