oops, typo there
the insert should be "left join" not just "left"
insert tableAselect * from tableB t1left join TableA t2 on t1.code = t2.codewhere t2.code is null
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
CREATE PROCEDURE updateinsert as BEGIN TRANSACTION BEGIN TRY update a set a.fname = b.fname, a.lname = b.fname from tableA a inner join table b on a.code = b.code insert tableA select * from tableB t1 left join TableA t2 on t1.code = t2.code where t2.code is null COMMIT END TRY BEGIN CATCH ROLLBACK END CATCH