Duplicate ID's

Results 1 to 2 of 2

Thread: Duplicate ID's

  1. #1
    Join Date
    Dec 1969

    Default Duplicate ID's

    I have multiple duplicate ID&#039s and was wondering how in the world I can delete them? I&#039m using SQL 7 and here&#039s the scenario....<BR><BR>The user has three records in the database with the same ID Number (not sure how this happened) but I&#039d like to delete 2 out of the 3 because I only need one of them to hold the data.<BR><BR>How can I go about deleting the other two without getting an error?<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: Duplicate ID's

    well that sucks. :) <BR><BR>you&#039ll have to first determine via SQL queries if those id fields have any dependant foreign keys. if they don&#039t have any dependencies - go ahead delete the record. if they DO, then start deleting the lowest level foreign key records, and work your way up until no constrainst are violated. FYI, the database won&#039t allow you to delete RI (referential integrity) - SQL Server will give you a contsraint error if you try deleting something that is part of an integral relationship.<BR><BR>SP_FKEYS [table_name_here] <BR>*try this stored proc to determine FKs of the table you wish to delete the multiple unique ID&#039s in.<BR><BR>what&#039s really interesting about this, is if the unique ID is an auto-number and SQL Server issued 3 SAME ID&#039S? hmmmph. <BR><BR>hope that helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts