diff --git a/plugins/sources/mssql.inc b/plugins/sources/mssql.inc index f8d2b1d..60484e9 100644 --- a/plugins/sources/mssql.inc +++ b/plugins/sources/mssql.inc @@ -160,7 +160,17 @@ class MigrateSourceMSSQL extends MigrateSource { $keys[0] . ' IN (' . implode(',', $this->idList) . ')', $this->query); } else { - if (isset($this->highwaterField['name']) && $highwater = $this->activeMigration->getHighwater()) { + $add_highwater_condition = TRUE; + // If there are any needs_update rows, we need to skip adding the + // highwater condition because it will interfere with the updates. + $count_needs_update = db_query('SELECT COUNT(*) FROM {' . + $this->activeMap->getQualifiedMapTable() . '} WHERE needs_update = 1') + ->fetchField(); + if ($count_needs_update > 0) { + $add_highwater_condition = FALSE; + } + + if ($add_highwater_condition && isset($this->highwaterField['name']) && $highwater = $this->activeMigration->getHighwater()) { if (empty($this->highwaterField['alias'])) { $highwater_name = $this->highwaterField['name']; }