AnsweredAssumed Answered

sql violation of unique key constraint

Question asked by AJZumwalt9 on Oct 3, 2017
Latest reply on Sep 21, 2018 by ahmadabusaleh

When I run the following script, which has run successfully for me on a number of other tables I get the following error:

Violation of UNIQUE KEY constraint 'versions_uk'. Cannot insert duplicate key in object 'dbo.SDE_versions'. The duplicate key value is (Poles, DBO).


The primary key for the Poles table is the ObjectID.


EXEC dbo.create_version 'dbo.DEFAULT', 'Poles', 1, 1, 'This version contains data pushed from WMM to ESRI';
EXEC dbo.set_current_version 'Poles';
EXEC dbo.edit_version 'Poles', 1;
MERGE ElectricNetwork.dbo.POLE_evw
USING WMM_Export.dbo.Pole
ON ElectricNetwork.dbo.POLE_evw.esElementName = WMM_Export.dbo.Pole.wmElementName
UPDATE SET ElectricNetwork.dbo.POLE_evw.GUID_WMM= WMM_Export.dbo.Pole.wm_ElementGuid;
EXEC dbo.edit_version 'Poles', 2;