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 |
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-06-06 : 19:45:20
|
| Hi,How would I select from TABLE A and add this data to TABLE B which has existing data that I want to keep. I would like to keep adding onto the old data. When I do an "Insert Into", it keeps on deleting my old data.Thanks, |
|
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-06-07 : 02:39:10
|
| Hello,The below code will help you, go through it...declare @Table1 Table(Col1 int,Col2 varchar(100))insert into @Table1(col1,col2)select 1, 'sql server' unionselect 2, 'oracle' unionselect 3, 'DB2' unionselect 4, 'my sql' unionselect 5, 'ms access' Declare @Table2 Table(col1 int,col2 varchar(100))insert into @Table2(col1,col2)select 1, 'aaaa' unionselect 2, 'bbbb' unionselect 3, 'cccc' unionselect 4, 'dddd' unionselect 5, 'eeee' Select col1,col2 from @Table2-- Inserting from Table1 to Table2insert into @Table2Select col1,col2 from @Table1select * from @Table2 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-07 : 04:40:38
|
quote: Originally posted by nguyenl Hi,How would I select from TABLE A and add this data to TABLE B which has existing data that I want to keep. I would like to keep adding onto the old data. When I do an "Insert Into", it keeps on deleting my old data.Thanks,
Not sure how your old data got deleted when you did insert into. Are you sure you didnt have a truncate/delete statement in batch? Or did you mean select into? |
 |
|
|
|
|
|
|
|