I'm attempting to repair a sql server instance on our server (new one) after our old one crashed. The program had to be re-installed and authorized with Ser# and AuthCode. After that process the program attempts to make connection to SQL database and allow connection to be made by workstation to server. I receive an error (taken from update.log file):
Error! Connectivity error: [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE UNIQUE INDEX terminated because a duplicate key was found for object name 'dbo.PRWHPLUS' and index name 'pk_PRWHPLUS'. The duplicate key value is (746). DOSQL(): ALTER TABLE PRWHPLUS ADD CONSTRAINT pk_PRWHPLUS PRIMARY KEY (nDetailID)
When i try to fix the issue and look into the database i find that the database has the primary key already setup, but this part of SQL is beyond me. Any help greatly appreciated.
The constraint exists, but you've got duplicate data. So you'll need to fix the data before proceeding.
Run this to see:
select nDetailID, COUNT(*) from PRWHPLUS group by nDetailID having COUNT(*) > 1
Anything returned by that means a duplicate of nDetailID exists. The second column in the output shows how many there are. You only want 1, and I've excluded anything with just 1 from the output.
There are several "deleting duplicates" solutions out there, so you can either google them or search SQLTeam for them.