Data Sync involving tables with auto-incrementing columns
hi all,
trying sync 2 tables between azure , on-premise db.
has identity column 'id' primary key.
1. after first run of sync, tables in both environments have max(id) 5.
2. deleted last row in on-premise , re-inserted achieve different id's same row. in on premise max(id) becomes 6. @ point, data in both environments same except different ids row.
3. new row inserted in azure db id = 6.
4. on running sync, on-premise row id=6 gets overwritten newly inserted row in azure. leads data loss in on-premise.
there way manage sync when inserts/updates/deletes going done @ both environments? when tables have identity columns?
i thinking not syncing identity column alone might work, since primary key, doesn't allow me leave out column.
please help!
thanksdeepthi
using identity columns pks on synchronization scenarios known issue regardless of whether use sql data sync service, sync fx or others (you'll find docs discouraging using identity-based pks)
there no api sql data sync, can't plug-in or intercept rows manipulate them. can't "trick" either use column pk.
in scenario, 1 possible workaround can "partition" identity values (similar way sql replication deals identity-based pks)
e.g., on-premise gets 1-1,000,000 azure db gets 1,000,001 n
not foolproof can "set identity insert" , insert potentially conflicting value.
Microsoft Azure > Azure SQL Database
Comments
Post a Comment