Create XML with variable element names from a data table with values and names
问题 I wasn't able to find a relevant post, so I decided to ask. I have the following table in my SQL Server database: ID attname value --------------------------------- 22405543 blktradind N 22405543 brkref IRVTGB2X 22405543 buyamt 104650.2000 22405543 buycurref USD 22405543 Buy53ref 22405543 Buy56ref 22405543 Buy57ref IRVTBEBB How can I convert this table by using FOR XML variations to a dynamic XML result based on the "attname" that each message has? For the excerpt above, the desired result