SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 SQL Error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Btimmerman
Starting Member

USA
2 Posts

Posted - 06/14/2012 :  17:28:10  Show Profile  Reply with Quote
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.

Thanks!

tkizer
Almighty SQL Goddess

USA
36845 Posts

Posted - 06/14/2012 :  17:38:31  Show Profile  Visit tkizer's Homepage  Reply with Quote
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.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Btimmerman
Starting Member

USA
2 Posts

Posted - 06/14/2012 :  17:50:01  Show Profile  Reply with Quote
It returns none...
Not sure how i can show you that - forum doesn't allow inserting images that i can tell...
?
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36845 Posts

Posted - 06/14/2012 :  18:07:58  Show Profile  Visit tkizer's Homepage  Reply with Quote
Maybe you have corruption due to the server crash. Run this and post the entire output: DBCC CHECKDB(DbNameGoesHere)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000