Duplication of Id's

  • There is a table which has structure:

    Table1 ( ID int , name varchar(200))

    here ID is FK

    We require is the name should be unique for each id.

    for eg :

    id = 12 name : test1 correct

    id = 12 name : test1 incorrect

    id = 13 name test1 correct

    The GUI passes error if duplicate name is accepted.

    But still in db we have duplicate name.

    I know I can make composite key. but I need to find out what is causing this,

    If code can pass error and there is no possibility who can figit with db, what can be the other reason for this duplication.

  • Check the strored procs and front-end code that you use to insert data for a bug that may be causing this.

    If you are not allowed to have duplicates of IDs then this should really be added as a unique constraint on that table, then you can be sure that this wont happen again.

  • No SP is involved when storing the name

    The code passes the error on duplication

    Still we have duplicate name.

    My probable guess is if user clicks on save tab multiple times the name gets saved.

    what say..

    I dont know much abt GUI,

    Even I tried creating one but failed

  • You will need to delete the duplicate row before creating the unique constraint.

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

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