Group_concat?

Jun 5, 2005

Is there anyway to concatenate the columns of a select statement over multiple rows

eg, say my select comes back with (its a big select with many joins etc)
FirstName LastName Other
Billy Bob Test1
Billy Bob Test2
Billy Bob Test3
Jon Smith fubar1
Jon Smith fubar2

I want it to return
Billy Bob Test1 Test2 Test3
Jon Smith fubar1 fubar2

I think the GROUP_CONCAT in mySQL performs this function, is there anything in ms sql

Thanks

Robbo

View 4 Replies


ADVERTISEMENT

How Can I Simulate Group_concat In SQL CE?

Apr 24, 2008

I am referring to the group concatenation where we get all the values of a single column (of all the rows) grouped into one cell as a concatenated string. I know I can achieve this using temporary tables and cursors in SQL Server. But I cannot have a cursor in SQL CE. I need to add this as a command to a tableadapter in a Dataset Designer. Please let me know if you can think of a workaround.

This is what I want:
Table 1:

Col1 Col2
1 a
1 b
2 c
2 d
2 e

Resultset should be:

Table 2:

Col1 Col2
1 a, b
2 c, d, e

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved