SQL Server 2012 Developer edition
TESTMACHINE:
OID MACHINENAME
---------------
1 TEST A
2 TEST B
3 TEST C
TESTDETAIL:
OID TESTMACHINEOID TESTID HISTORYID
-------------------------------------
1 1 200 100
2 1 300 250
3 2 1000 2345
4 3 100 150
TestMachineOID is the FK to the TestMachine table
I need to concatenate items into an XML by grouping TestMachineOID. Is it possible to get the below desired output?
TESTMACHINEOID TESTMACHINENAME TEXTXML
------------------------------------------------------------------------
1 TEST A <REC><TESTID>200</TESTID><HISTORYID>100<HISTORYID><TESTID>300</TESTID><HISTORYID>250<HISTORYID></REC>
2 TEST B <REC><TESTID>1000</TESTID><HISTORYID>2345<HISTORYID></REC>
3 TEST C <REC><TESTID>100</TESTID><HISTORYID>150<HISTORYID></REC>