last record in table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pranjalraje
    New Member
    • Sep 2006
    • 1

    last record in table

    can you please help me with sql querry for 'finding last record in a table'
  • Prarthana Choudhary
    New Member
    • Aug 2006
    • 7

    #2
    Hi,
    Inherently, a relational database table is a set. Sets are, by definition, unordered.
    So every select statement will show you records in different order , i mean no order, it will be in random order.Getting the last row requires that you have some way of ordering the rows in the database.
    If you do not have an identity column, you would need to have some other "identity-like" column, such as a column that holds the last modified date of a row or atleast some serial number as primary key .
    Otherwise, SQL Server has no way of identifying the last record.

    Comment

    • ramasp
      New Member
      • Sep 2006
      • 19

      #3
      Hi,
      Answer for your question
      ------------------------------------
      select top 1 * from tablename order by column name desc

      Comment

      Working...