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 |
david_reinjal
Starting Member
36 Posts |
Posted - 2007-12-07 : 01:22:38
|
hi guys,i have a table with 2 columns say:First_Name Last_NameDavid Reinjali need to merge these 2 columns and put into a single column with a ','(comma) seperated. it will look loke this:column_nameDavid, Reinjalhow can i do this? can anybody help me in this?thanks,David |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-07 : 01:46:06
|
select first_name +','+coalesce(last_name,'') as column_name from tableMadhivananFailing to plan is Planning to fail |
|
|
david_reinjal
Starting Member
36 Posts |
Posted - 2007-12-07 : 01:54:25
|
thnx man..but actually i wanted multiple rows into a single record. like:First_nameDavidMadhivananthis has to be put in a single record with a ',' seperator. but i need to use a where clause to specify which names in a state should be merged. for instance:State First_nameKar Davidkar Madhivanan Mum Mohanso all the names in Kar should me merged in a single record with a ',' seperator. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-12-07 : 02:10:28
|
or maybeselect RTRIM(first_name) +','+coalesce(last_name,'') as column_name from table |
|
|
|
|
|