Sunday, December 5, 2010

MS SQL to produce XMl data rows from JOINed select statement

Programmer Question

I have a three tables in SQL server 2008 which are setup as follows:



EMPLOYEE TABLE



empid(PK)
1
2



joined to EMPLOYEEATTRIBUTES



dataId(PK) | empId(FK) | attributeid | attributeVal
10 | 1 | A1 | somevalue1
20 | 1 | A2 | somevalue2
30 | 2 | A1 | somevalue3
40 | 2 | A3 | somevalue4



joined to ATTRIBUTES



attributeid | attributeName
A1 | attribute1
A2 | attribute2
A3 | attribute3



I need to get the xml data out into the following format





somevalue1
somevalue2


somevalue3
somevalue4



Anyone know how this can be done??



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails