Home > OS >  SQL FOR XML attribute & value
SQL FOR XML attribute & value

Time:10-07

I've been searching for quite some hours now to generate this line of XML from an sql query. Never needed to include both a value and an attribute in one 'FOR XML' line. Many thanks for the help.

    <Amount Ccy=”EUR”>100.20</Amount>

CodePudding user response:

You can try this

SELECT 
   CCY as "Amount/@CCY", 
   Amount, 
   null
FROM <db.schema.tablename>
WHERE  conditions for xml path
  • Related