• If there is another field in the table that would determine which of the duplicate records you want to keep (such as the oldest record) you could key off that to remove the duplicates.

    /* Set up the test table */

    Declare @phonenum table (phone varchar(10), pdate int)

    insert

    into @phonenum (phone,pdate)

    select 1,1 union all

    select 2,2 union all

    select 3,3 union all

    select 3,2 union all

    select 4,2 union all

    select 5,1 union all

    select 5,7 union all

    select 5,3 union all

    select 5,1 union all

    select 6,1

    select 'original table', phone, pdate

    from @phonenum

    order by phone, pdate

    /* copy the non-dups from the original table based on oldest date */

    select phone,pdate

    into #temptab

    from

    (select p.phone,p.pdate

    from @phonenum p

    join @phonenum p2

    on p.phone = p2.phone

    GROUP BY p.phone,p.pdate having p.pdate = min(p2.pdate)) t

    select 'temporary table - non-dups with oldest date', phone, pdate from #temptab

    order by phone

    drop table #temptab

    If you need another tiebreaker when the dates are also the same, add that to the selection criteria. If it doesn't matter if the dates are the same, this will just put one of the records out there.

    It is always good to review the data before running any updates or deletes so you can see if there are any special cases to take into account.

    Toni