I have a table in my database that looks like this:
@attribute element data
--------------------------------------
attribute1 element1 data1
attribute2 element2 data2
I want to output XML that looks like this:
<element1 attribute="attribute1">data1</element1>
<element2 attribute="attribute2">data2</element2>
There are about 30 attribute element names, sorry, and they're somewhat dynamic. I'm not all that practiced or knowledgeable in SQL. Is there a straightforward solution? Barring that, is there a "best-practice" solution? If I use dynamic SQL, what measures should I take to catch/prevent potential errors?