Link to home
Start Free TrialLog in
Avatar of soozh
soozhFlag for Sweden

asked on

Query syntax

Hello,

I have a table (see below) that contains a series of name/value pairs for a document.   The document is identified by the DocumentId column.  The name and values are given by the FieldName and FieldValue columns.  There is also a column called Changed (which is true when the FieldValue has been changed).

I need to produce an XML document like that shown below the table.   The elements are the name/value pairs.  Note that Changed must be an attribute of the element.

Do i need to pivot the data first, and then generate the xml?

How should the query look like?


Id	DocumentId	FieldName	FieldValue	                       Changed
161	9	                 text1		 Another form.	                        0
163	9	                 text2		 Soon it is time for lunch.!.	       1
165	9	                 colour		 3	                                          0

Open in new window


<Dataset>
<DocumentId>9</DocumentId>
<text1 changed=”0”>Another form</text1>
<text2 changed=”1”> Soon it is time for lunch.!</text2>
<colour changed=”0”>3</color>
<Dataset>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soozh

ASKER

Thanks for the help.  I had to add some isnull statements because some of the columns had null values...