Her er A måde at gøre det på (virker også med 2005):
Tabel
DECLARE @table TABEL ( [Type_ID] INT, [Client_ID] VARCHAR(50), [PBX_Vendor] VARCHAR(50) )
Data
INSERT INTO @table SELECT 127, '090820006311404926326C', 'Aastra' UNION ALL SELECT 127, '090820006311404926326C', 'Ericsson' UNION ALL SELECT 7, '2411C SELECT, '1241CALL', '1241C SELECT, '1241CALL', '1241C SELECT', '1241CALL' 120209287521404926326C', 'Aastra' UNION ALL SELECT 127, '120209287521404926326C', 'Alcatel'
Forespørgsel
VÆLG [Type_ID], [Client_ID], ( SELECT TING(( SELECT ',' + [PBX_Vendor] FROM @table WHERE [Client_ID] =tbl.[Client_ID] AND [Type_ID] =tbl.[Type_ID] ] GRUPPER EFTER [PBX_Vendor] BESTIL AF [PBX_Vendor] FOR XML PATH('') ), 1, 1, '') ) PBX_VendorFROM @table tblGROUP BY [Type_ID], [Client_ID]
Resultat
Type_ID Client_ID PBX_Vendor127 090820006311404926326C Aastra,Ericsson127 111012237401404926326C Aastra127 12020942872Catel