johnnyg123
asked on
Insert new records
I have 2 tables on sql server 2008 database
with same fields
Playerid, street, city, state, zip
AddressMaster has master list of addresses
Addressupdate has address updates
How do I insert addresses in address updates that are not in address master?
with same fields
Playerid, street, city, state, zip
AddressMaster has master list of addresses
Addressupdate has address updates
How do I insert addresses in address updates that are not in address master?
this may perform better
insert into AddressMaster
select * from Addressupdate u left join AddressMaster m on u.playerid=m.playerid
where m.playerid is null
insert into AddressMaster
select * from Addressupdate u left join AddressMaster m on u.playerid=m.playerid
where m.playerid is null
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(From the way you asked the question, I'm assuming that some of the data in AddressUpdate is already in AddressMaster. Otherwise the simple SELECT statments will work fine.)
insert into AddressMaster
select * from Addressupdate where playerid not in (select playerid from AddressMaster)