Several agents within a response group, group had their SIP address modified and when attempting to re-add their updated account the following error message appeared:
Cannot insert duplicate key row in object ‘dbo.Agents’ with unique index ‘IX_Agents_UserSid’. The duplicate key value is (0xxxxxx). The statement has been terminated.
When attempting to also modifying the agents in the group via the Lync management shell the identical error appears.
I have found several blogs walking through manually modifying the databases themselves, however in this situation I did not have access to those databases.
There’s potentially 2 fixes to this that I had in my situation. The first may be one of the agents NT accounts is disabled and you need to remove them and commit the settings before being able to remove the rest.
The second is you simply may just need to remove all the stale accounts (those that SIP addresses are no longer accurate), commit the changes and then re-add the users with their updated SIP address.
It seems like such a simple fix however judging by the other blogs with this error, it’s caused quite a few of us Lync admins to spend some time on it. Hopefully this saves you an hour of troubleshooting.