Home Forums SQL Server 2008 T-SQL (SS2K8) Retrieve results from table with latest timestamp RE: Retrieve results from table with latest timestamp

  • Nidhi G (12/24/2012)


    How do I delete one entry then?

    this query will help you to remove duplicates

    delete t from

    (

    select ROW_NUMBER() over (partition by Id order by Id ) as rank1,* from syn_trans) t

    where t.rank1 <> 1

    THOUGH it doesnt guarantee about the newest or oldest record deletion because you are not maintainig that OR you can add one another column like created_date (timestamp) or any identity column to maintain the sequence.

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)