Skip to content
Advertisement

Delete duplicated rows and Update references

How do I Delete duplicated rows in one Table and update References in another table to the remaining row? The duplication only occurs in the name. The Id Columns are Identity columns.

Example:

Assume we have two tables Doubles and Data.

Now I Have Two entries in the Doubls table:

And two entries in the Data Table:

At the end there should be only one entry in the Doubles Table:

And two entries in the Data Table:

In the doubles Table there can be any number of duplicated rows per name (up to 30) and also regular ‘single’ rows.

Advertisement

Answer

I’ve not run this, but hopefully it should be correct, and close enough to the final soln to get you there. Let me know any mistakes if you like and I’ll update the answer.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement