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)


    Hi,

    I have a table with syn_trans with below cols:

    (

    Id integer(10),

    Name varchar2(100),

    seq_no integer(10),

    seq_name varchar2(100),

    gp_name varchar2(100)

    )

    There is no unique/primary key on the table.

    A row exists in table with below values:

    INSERT INTO syn_trans VALUES(60175,'AccountOverview',0,'Signon','StepGp');

    Two days later I again execute the same insert statement and now there exists two records for the ID=60175

    I want to retrieve the entry with latest timestamp or in other words I want to delete the entry for this ID which I added second time.

    Plz provide the SQL for this.

    Thanks in advance.

    First, there is nothing in the table structure to tell which record is inserted first. Second, if they are completely identical, does it really matter which of the duplicate records gets deleted?