Saving problem in SQL server 2000 database table

  • Hello, guys how are you doing?

    I am trying to modify tables from temporary to permanent data ( design tables between the two tables and the permanent data of "Appdetail" unable to accept the primary key. and the error says-

    'AppDetail' table

    - Unable to create index 'PK_AppDetail'.

    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 '25250'.

    [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.

    please help me guys

  • The error is trying to tell you that the column you are trying to make into a primary key has duplicate values in it (each row must has a unique non-null value in a column for that column to be a PK).

    try running code something like this to find your duplicates:

    select myPrimaryKeyCandidate,count(*)

    from myTable

    group by myPrimaryKeyCandidate

    HAVING count(*)>1

    You will then have to "fix" the duplicates in some way.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Hi, matt miller

    I have copied the code that you gave me and pasted into SQL Query analyzer. and the error says-

    " Server: Msg 208, Level 16, State 1, Line 1

    Invalid object name 'myTable'."

    then i changed also" myTable" to " AppDetail" and the error says

    " Server: Msg 207, Level 16, State 3, Line 1

    Invalid column name 'myPrimaryKeyCandidate'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'myPrimaryKeyCandidate'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'myPrimaryKeyCandidate'."

    I think this is clear for you

    thanks

  • massawa (1/15/2008)


    Hi, matt miller

    I have copied the code that you gave me and pasted into SQL Query analyzer. and the error says-

    " Server: Msg 208, Level 16, State 1, Line 1

    Invalid object name 'myTable'."

    then i changed also" myTable" to " AppDetail" and the error says

    " Server: Msg 207, Level 16, State 3, Line 1

    Invalid column name 'myPrimaryKeyCandidate'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'myPrimaryKeyCandidate'.

    Server: Msg 207, Level 16, State 1, Line 1

    Invalid column name 'myPrimaryKeyCandidate'."

    I think this is clear for you

    thanks

    "myPrimaryKeyCandidate" was just an example. You need to replace it with the name of the attempted column name you are trying to make into a primary key.

  • yes, exactly and i did it well

    thank you very much

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply