Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comma separated values
Message
From
17/04/2013 04:29:11
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01571086
Message ID:
01571182
Views:
40
>>Hi
>>
>>I've got a table individual and a table attribute in SQL2008
>>
>>A line in individual can have several entries in attribute linked on indvividual_ref.
>>
>>I want to produce a result with indvidual_ref,attribute_string
>>
>>where attribute string is a delimited string of all the attribute codes for that individual
>>
>>Any tips on how I'd get that.
>>
>>Thanks
>>
>>Nick
>
>select I.*, stuff((select ', ' + attribute from dbo.Attribute A where A.Individual_ID = I.Individual_ID
>order by Attribute FOR XML PATH(''), type).value('.', 'varchar(max)'),1,2,'')  as Attribute_String
>from dbo.Individual I ORDER BY I.LastName
>
>Take a look at this blog post
>
>Making a list and checking it twice

Thanks Naomi thats perfect.
Previous
Reply
Map
View

Click here to load this message in the networking platform