Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comma separated values
Message
 
 
À
16/04/2013 11:38:57
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:
01571088
Vues:
60
This message has been marked as the solution to the initial question of the thread.
>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
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform