Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Concatenate Column
Message
De
22/02/2003 11:04:05
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00756491
Message ID:
00756568
Vues:
23
Thanks for that.

Can we use this in-line to make a derived table?

select somefield from sometable inner join (DECLARE @StrConcat varchar(8000)
SET @StrConcat = ''
SELECT somefield,@StrConcat = @StrConcat + ', ' + title_id
FROM sometable
GROUP BY somefield) dt_concat on sometable.somefield = dt_concat.somefield

Or should I create a procedure and call it as a derived field?

>>Hi all
>>
>>Is there any way with SQL Server and SPT to concatenate a set of entries into a string much as SUM() sums a set of entries into a total?
>
>Mike,
>There's set based solution if you want to concatenate column from all records that satisfy query conditions.
TEXT TO lcSql NOSHOW
>DECLARE @StrConcat varchar(8000)
>SET @StrConcat = ''
>SELECT  @StrConcat =  @StrConcat + ', ' + title_id
>	FROM pubs..sales
>	WHERE stor_id LIKE '7%'
>SELECT SUBSTRING(@StrConcat,3,8000)
>ENDTEXT
>? SqlExec(lnConn, lcSql)
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform