• It's a lot more complex problem.

    In a well designed database there should be no duplicates.

    The simplest solution is to have proper constraints (primary, unique key) and have trigger validation on at least natural keys

    Insert into #Employee VALUES (1, 'Mark Dunn', 'HR');

    Insert into #Employee VALUES (2, 'Mark.Dunn', 'HR');

    Insert into #Employee VALUES (3, 'Mark Dunn', 'HR');

    Based on name column, these are duplicates as well, but would pass index constraints, so you have to check on normalized form of name in insert/update trigger.

    It can still happen a user (curse them!) finds a pattern not covered in your trigger logic and inserts a sort-of-duplicate.

    Second part of the problem is how to merge such duplicates as they may have a lot of references.

    Just a bit of food for thought. 🙂