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 |
|
CLEE25
Starting Member
14 Posts |
Posted - 2008-12-11 : 20:43:02
|
| Hey all, I have two tablesTemp (ID, Name)Solid (ID, Name)What I am looking to do is update the Solid Table from the temp table--which I have already done. What I want to do next is delete the records in the Temp Table that have been updated. Ie, I want to delete the records in the Temp Table where the Temp.ID=Solid.IDThen I plan to import what is left in the temp table (those records without a matching ID) as new records in the Solid Table. Can anyone give a statement? Something likeDelete from Temp where (Temp.ID=Solid.ID)Thanks for any help! |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2008-12-11 : 23:01:16
|
| create table temp(id int ,name varchar(32))insert into temp select 1,'kk'create table temp1(id int ,name varchar(32))insert into temp1 select 1,'sdf'delete temp where temp.id in (select id from temp1) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-11 : 23:23:08
|
or use joinDELETE t FROM Temp t JOIN Solid s ON s.ID=t.ID |
 |
|
|
CLEE25
Starting Member
14 Posts |
Posted - 2008-12-12 : 11:55:56
|
| Thanks so much all!visakh16 the code worked perfect. I owe you! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-13 : 00:38:11
|
no problem... you're welcome |
 |
|
|
|
|
|