Row Number

  • I am doinga  select from tablea joining onto tableB. Alll data is retrieved correctly is it possible to get a field which would display the ownumber also along with th select. Any help on this will be greatly appreciated.

    TIA

  • Which version of SQL Server ? SQL 2005 has ranking functions which can supply a row number.

    In SQL 2000, you'd need to first select into a temporary table with an Identity column, then perform your final select out of that table.

     

  • Thanks I am using sql 2000 only and you are right i couldnt see any other way other than usinga temp tablle with an identity col.

    TIA

  • Why can't you simply add the counter in the application when displaying the data?

  • Is that something that could be done from the back end or you are saying to have the counter at front end side? Can you please clarify. TIA

  • I'm saying that when you're presenting the data like in a asp report.  You can manually add that counter with a variable.  Isn't this option available to you?

  • SELECT  IDENTITY(int, 1, 1) AS RowNum, CustomerID into #tmpA from northwind.dbo.orders

    select * from #tmpA

Viewing 7 posts - 1 through 6 (of 6 total)

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