Getting Row Number

  • Hi,

    Does anyone know if SQL Server has a @@ROWID variable or function that gives me the row number the query is on?

    For exampe if I select 5 quiries from an employee table:

    SELECT FirstName, LastName, Age, @@ROWID

    it gives me

    John, Smith, 40, 1

    Jane, Doe, 34, 2

    Josh, Cooper, 44, 3

    keeps incrementing automatically when displaying each row

    Bob

  • Unfortunately SQL 2000 does not have a row number function, you'll have to wait for SQL 2005 for that

    In the meantime, take a look at these articles and choose the best workaround that suits,

    http://www.aspfaq.com/show.asp?id=2427

    http://databasejournal.com/features/mssql/article.php/10894_2244821_1

     

    --------------------
    Colt 45 - the original point and click interface

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply