yep, here ya go:set nocount ondeclare @tableA table (id int, col1 int)declare @tableB table (id int, col1 int)insert @tableA Select 1,1 union select 2,1insert @tableB Select 2,2 union select 3,3print 'before update'Select * from @TableA--updateupdate a set a.col1 = b.col1from @tableA aJOIN @tableB b ON a.id = b.idprint 'after update'SElect * from @TableA/*--insert (where not exists)insert @TableA (col1) Select col1From @TableB bWhere NOT Exists(Select * from @TableA where col1 = b.col1)*/--insert (left outer join)insert @tableA (col1)Select b.col1From @TableB bLeft JOIN @TableA a ON a.id = b.idWhere a.id is NULLprint 'after insert and update'Select * from @TableA
Be One with the OptimizerTG