Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to write this query?

0 views
Skip to first unread message

laredotornado

unread,
Aug 30, 2010, 10:43:24 AM8/30/10
to
Hi,

I'm using SQL Server 2005. I have a query that returns multiple rows
in which all the column values are the same except one ...

Results
id text category
=====================
2 Hello ABC
2 Hello DEF

Does anyone know how I would write this query such that I could
combine into a comma-separated list, the "category" column, so that
the results would return as a single row -- e.g.

id text category
=====================
2 Hello ABC, DEF

Thanks, - Dave

Sylvain Lafontaine

unread,
Aug 30, 2010, 11:10:17 AM8/30/10
to
Search the web for "sql-server rows concatenation" or "rows aggregation".
For example, see the following articles from Anith Sen and others:

http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/

http://www.projectdmx.com/tsql/rowconcatenate.aspx

--
Sylvain Lafontaine, ing.
MVP - Access
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)


"laredotornado" <laredo...@zipmail.com> wrote in message
news:7bb49d5b-dfc7-444b...@y32g2000prc.googlegroups.com...

--CELKO--

unread,
Aug 30, 2010, 11:45:57 AM8/30/10
to
Do this kind of formatting in the front end and not the database. It
is called violating First Normal Form (1NF).
0 new messages