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 |
|
Starsky51
Starting Member
2 Posts |
Posted - 2010-09-29 : 07:26:49
|
| HI all,I have a bd that has 10 columns named user1,user2 etc and 10 columns named dispo1, dispo2 etc and I want to just join all the users together in 1 column and all the dispo in another column. Can anybody help me with this? |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-09-29 : 12:03:24
|
| Select user1 + ',' + User2 -- and so onas UserColumn,dispo1 + ',' + dispo2 -- and so onas DispColumnFrom YourTableIf any column is nullable make sure to use IsNullEx:Select Isnull(user1 + ',','') + User2 --Assuming that User1 is nullable and User2 is not null column. |
 |
|
|
da42
Starting Member
3 Posts |
Posted - 2010-09-29 : 12:29:42
|
| Also, if any of your fields are integer/float/etc, you might get an error trying to mathematically ADD+ a ',' comma to it, so you might need to do a convert to nvarchar or some other type before concatenating. Have seen that before. |
 |
|
|
|
|
|