jeudi 21 juillet 2016

Couple columns from result into one separated with comma

I got this query

declare var1 nvarchar(100)
    set @var1='84,85,86'
    SET @sql = N'select a1 from DamDocumentType1 where documentid in (' + @var1 + ')' ;
    EXEC (@SQL);

The result i get comes in one column and 4 rows. For example:

3/2014

4/2014

5/2014

8/2014

How can i put this couple of rows in one row and one column and separate them with comma.For example:

3/2014,4/2014,5/2014,8/2014

I use that query for something so now i need it fixed to do this thing i just explained, i cant figure it out. You can say that I'm new in this :)

Aucun commentaire:

Enregistrer un commentaire