Thursday, July 11, 2013

[Replication] Fun little gotcha with tables that have a UNIQUE index/constraint.

So I've been bitching to one of our devs about how his updates to a replicated table suck.  Today I went looking.  What the.... it issues a delete, then inserts the row?  Why are you doing it that way?  Well, he's not.  SQL is.  : - \

Turns out, if you have a unique index or constraint (as opposed to the default PK index, I suppose...), then it deletes then inserts the row.  Which sucks when you have a massive wide table with a ton of records.

Live and learn.  Hopefully this helps somebody else.

https://blogs.msdn.com/b/repltalk/archive/2011/10/04/sql-server-transaction-replication-bounded-update-or-why-my-update-was-transformed-into-an-delete-insert-pair.aspx?Redirected=true

No comments: