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 |
|
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-11-29 : 16:47:40
|
| Hi,I have two tables with same columns but different values in these columns. I would like to combine both tables and combine the values in each columns. What is the best way to do that? thanks! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-11-29 : 21:39:02
|
| Depends on what you want to do.Possibly a union or union all?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2010-11-29 : 22:01:21
|
Could even be an UPDATE Update tableASet TableA.ColumnName = TableB.ColumnNameFROM TableA inner join TableB ON TableA.ID = TableB.ID Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-12-01 : 12:58:08
|
| by combine do you mean aggregate values in corresponding columns? also do you have common valued column(s) using which you can correlate records------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-12-01 : 13:43:12
|
| basically there are two identical tables with different values in the columns. I want to aggregate these values and I think the UNITE statement will work well.thanks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-12-01 : 13:47:44
|
there's no UNITE statement in SQL Server. you must be using UPDATE likeUpdate tableASet TableA.ColumnName = TableA.ColumnName + TableB.ColumnName ,..FROM TableA inner join TableB ON TableA.ID = TableB.ID ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
VeselaApo
Posting Yak Master
114 Posts |
Posted - 2010-12-02 : 10:57:04
|
| Thanks Visakh! |
 |
|
|
|
|
|