The stated purpose of your query is to return new and updated rows from [ExternalTable]
. In that case you could use EXCEPT
syntax. You might also want to use temp table for [ExternalTable]
, because the estimates for it seem totaly wrong in the execution plan you provided. The query would look like this:
SELECT foo, bar, dataINTO #tFROM [ExternalTable]SELECT foo, bar, dataFROM #tEXCEPTSELECT foo, bar, dataFROM [Table]