Posts

Showing posts with the label upsert

T-sql merge to partial target table by where-clause

/* Example of how to merge partial set of target table  In this example I merge from #mysource to #mytarget, but only affect type='car' */   if   object_id ( 'tempdb..#mytarget' )   is   not   null     drop   table   #mytarget if   object_id ( 'tempdb..#mysource' )   is   not   null     drop   table   #mysource create   table   #mytarget   (   id   int   not   null ,     type   varchar ( 100 )   not   null ,      name   varchar ( 100 )   not   null   ) create   table   #mysource   (   id   int   not   null ,     type   varchar ( 100 )   not   null ,      name   varchar ( 100 )   not   null ...