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.
| Author |
Topic |
|
iqmcl
Starting Member
8 Posts |
Posted - 2009-12-05 : 03:48:01
|
| Hi,I may be missing a very simple solution, but would appreciate some help. I have a simple table, in this example contains 6 rows, I want to merge the second column data, based on email address. So raw data looks like this;email varcharcolumnjohn@smith.com test 1john@smith.com test 2john@smith.com test 3a@b.com test 3c@d.com test 1c@d.com test 2and i want a select statement to return the varchar column concatenated;john@smith.com test1,test2,test3a@b.com test3c@d.com test1,test2Any help is appreciated.CheersChris |
|
|
ddramireddy
Yak Posting Veteran
81 Posts |
Posted - 2009-12-05 : 12:43:45
|
| select distinct email, stuff((select ',' + varcharcolumn from tablename where email = t.email for xml path('')),1,1,'') from tablename t |
 |
|
|
|
|
|