I am trying to convert the tables:
- tblCustomAttributeSourceSchema that contains the COLUMN DEFINITIONS and
- tblLabelAttributes that contains the VALUES for each of the columns
For your convenience I created the tables in this sqlfiddle:
http://www.sqlfiddle.com/#!6/b2fde/1
I would like to convert this to a table containing "LabelID" (of type INT - originally from tblLabelAttributes) and "XML_VALUE" (of type XML) as per the following example. So for labelID=688 it should be:
<attributes>
<attribute attribute_id="1" value="2.00" />
<attribute attribute_id="2" value="3.00" />
<attribute attribute_id="3" value="60.00"/>
</attributes>
The "attribute_id" should be set to the AttributeID from tblCustomAttributeSourceSchema and the "value" should be set to the value in tblLabelAttributes.
If an attribute value is null in '"tblLabelAttributes"' then the "attribute" record should be missing in the XML for that LabelID.
I am not very familiar with XML functionality in SQL Server. I am looking for how I could go about converting the data to such an XML. Any help would be greatly appreciated.