none
how can I delete the last latest record? RRS feed

  • Question

  • delete TOP 1 * FROM tablename ORDER BY ID DESC

     

    how can I delete the last latest record?

    Wednesday, August 27, 2008 7:21 AM

Answers

  • Is the ID column an identity column?

    If so, you can do sth. like that:

     

    Code Snippet

     

    DELETE FROM tablename

    WHERE ID =

    ( SELECT MAX(ID) FROM tablename )

     

     

     

     

     

    Wednesday, August 27, 2008 7:40 AM

All replies

  • Is the ID column an identity column?

    If so, you can do sth. like that:

     

    Code Snippet

     

    DELETE FROM tablename

    WHERE ID =

    ( SELECT MAX(ID) FROM tablename )

     

     

     

     

     

    Wednesday, August 27, 2008 7:40 AM
  • DELETE TOP .... can not insure the record which you want to delete is the lastest record

    Wednesday, August 27, 2008 9:04 AM