Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comma separated values
Message
De
17/04/2013 04:29:11
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Divers
Thread ID:
01571086
Message ID:
01571182
Vues:
42
>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform