Link to home
Start Free TrialLog in
Avatar of liqiug
liqiug

asked on

How to convert multiline recordset to comma sperated string in sql server

Hi,
say I have a table  in Sql server 2005
name   value1  value2
name1  v11        v121
name1  v12        v122
name2   v21      v211
name2   v22      v222

how can I get a record set to  with one sql statement , no cursor , no procedure?

name   value1          value2
name1   v11,v12      v121,v122
name2   v21,v22      v211,v222
Avatar of RiteshShah
RiteshShah
Flag of India image

you have to create one function with coalesce which can return comma separated value and integrate it in your query.

to know the use of COALESCE, have a look at my article at

http://www.sqlhub.com/2008/04/coalesce-function-in-sql-server-for.html
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of liqiug
liqiug

ASKER

Excellent!
Thank you