Groups | Blog | Home
all groups > sql server (alternate) > january 2004 >

sql server (alternate) : Primary Key problems


tcumming NO[at]SPAM smorgonsteel.com.au
1/27/2004 10:20:49 PM
Hi there,

I just tried to apply a set of primary keys to a table and after a
very long time (like an hour or more) i got this error message ....

Unable to create index 'PK_master_data'.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE
UNIQUE INDEX terminated because a duplicate key was found for index ID
1. Most significant primary key is '2050500'.
[Microsoft][ODBC SQL Server Driver][SQL Server]Could not create
constraint. See previous errors.
[Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been
terminated.

..... i am new to sqlserver ... is this saying to me that i have a
duplicate record? because when i query the recordset for duplicate
records i get none!

please help ASAP.

Thanks

sql NO[at]SPAM hayes.ch
1/28/2004 2:24:08 AM
[quoted text, click to view]

Yes, there are duplicates. How are you querying the recordset for
them? A query like this should find them:

select PrimaryKeyColumn, count(*)
from dbo.MyTable
group by PrimaryKeyColumn
having count(*) > 1

AddThis Social Bookmark Button