• ben.brugman (8/3/2015)


    This weekend I have been away from the keyboard. And as often the best idea's occure when away from the keyboard. E.g. on my bike (pushbike) or under the shower. This weekend I came up with the following:

    select * into #D from D1

    Delete D1

    insert into D1 select distinct * from #D

    This works for most tables.

    But does not work for tables which have an identity and not for tables with the larger datatypes like XML.

    Maybe I should take more showers.;-)

    Thanks all for you time and attention.

    Ben

    Also wouldn't work if you have a TIMESTAMP column. Actually, the SELECT * INTO would work but the INSERT INTO would fail.

    There is a way to make this idea work but there are some rules to make it happen.