Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Holland
    Posts
    18

    Unanswered: SQL Query question.

    How can I manually delete the four last records in a table? I want to do this with a query.

    Is this possible?

    Thanks in advance!

  2. #2
    Join Date
    Dec 2003
    Location
    Houston, TX
    Posts
    6
    If you have an identity column in your table, you could do something like
    Code:
    DELETE Table_Name
    WHERE ID_Column IN
         (SELECT TOP 4 ID_Column
         FROM Table_Name
         ORDER BY ID_Column DESC)
    It would get more complicated if you don't have an identity field, but still possible based on what sort of data you're storing. If you don't have an identity column, could you share your table layout?

  3. #3
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    What is the Primary Key (PK) and how do you determine the "order" of the rows in the table? Tables don't have any implicit order, so you need to decide how you want the rows ordered. The PK is the column or columns that uniquely identify each row in your table.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •