I have 2 table TableA and TableB I want to insert all records at a time from TableA to TableB if the records are not in TableB
Please help thank you
I have 2 table TableA and TableB I want to insert all records at a time from TableA to TableB if the records are not in TableB
Please help thank you
Assuming they are sharing the same primary key.
insert TableB
select A.* 
from TableA A 
left join TableB B ON A.pk = B.pk 
where B.pk is null
This should work
INSERT INTO TableB
SELECT * FROM TableA
EXCEPT
SELECT * FROM TableB
Alternate form of sambo's answer.
INSERT TableB
SELECT *
FROM TableA A
WHERE NOT EXISTS (
    SELECT *
    FROM TableB B
    WHERE A.pk = B.pk )