Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 how to merge data in comma format by group in sql

Author  Topic 

dharmsah
Starting Member

1 Post

Posted - 2011-02-01 : 03:37:22
hi

Could any one help me how to get rid of my problem

My problem is:
table name: countryID

accid names
——————————–
101 india
102 india
103 india

201 usa
202 usa
————————————————

I need like this

names accid
————————————————–
india 101,102,103
usa 201,202
—————————————————

please how to solve this problem.

Regards
Dharmendra Kumar


TheRedman
Starting Member

1 Post

Posted - 2011-02-01 : 18:04:46
Hi Dharmendra
Tryout this link
http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
Go to Top of Page

yadhu_cse
Constraint Violating Yak Guru

252 Posts

Posted - 2011-02-02 : 00:27:51
Try this


select field1 + field2 from table name

or

select field1 || field2 from table name

Go to Top of Page
   

- Advertisement -