Primary Key problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mogi

    Primary Key problems

    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

    Mogi
  • Simon Hayes

    #2
    Re: Primary Key problems

    tcumming@smorgo nsteel.com.au (mogi) wrote in message news:<d1729549. 0401272220.49ea 5ee6@posting.go ogle.com>...[color=blue]
    > 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
    >
    > Mogi[/color]

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

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

    Simon

    Comment

    Working...