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 |
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-08-22 : 08:19:44
|
| I have two tables. CREATE TABLE TEMP(KEYNAME VARCHAR(256),LOCALE VARCHAR (20),VALUE ntext)goCREATE TABLE keys_1(KEYNAME VARCHAR(256),LOCALE VARCHAR (20),VALUE ntext)goWhat I need is i need to update the second table with the freshly loaded data in the first table. but if the data is already present in second table i only need to update the existing rows, if it is not there i have to insert the rows. i am not able to think of anything. Can someone help? i used except and minus, i am able to see the difference. But after that i am not able to do anything..thnx in advance |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-22 : 08:37:42
|
| General approachUpdate t2set t2.col1=t1.col1,....from table1 t1 inner join table2 t2 on t1.keycol=t2.keycolInsert into table2(columns)select columns from table1 t1where not exists(select * from table2 where keycol=t1.keycol)MadhivananFailing to plan is Planning to fail |
 |
|
|
abhwhiz
Starting Member
37 Posts |
Posted - 2007-08-22 : 11:04:10
|
| that was gr8 madhi,yeah, it suddenly looked surpringly simple. i modified the first script for my need (and i was successful too) , second one worked straightaway. i am learning a lot nowadays and thnx for that. i guess the issue was i was thinking about the answer too much.once again thnx... |
 |
|
|
|
|
|