Serial no in result set of a Query

  • I have joined many tables and made a select statement. I need to display serial no as first column in the result set of the query, ie. if the result set contains 10 records then the serial no column must show from 1 to 10, each no for each row or record. Is there any built in function in SQL or any other method to do this task.

    I would be very thankfull if anyone suggest a solution for this.....

  • Lookup ROW_NUMBER in SQL Server 2005 Books Online

  • Am using SQL 2000..

  • @jit fr Cochin (1/11/2009)


    Am using SQL 2000..

    Please post SQL 2000-related questions in the SQL 2000 forums in the future. If you post in the 2005 forums, you're very likely to get 2005-specific solutions.

    You can insert the result of the query into a temp table or table variable that has an identity and select from that. It's probably the easiest way on SQL 2000.

    Continued here: http://www.sqlservercentral.com/Forums/Topic634119-8-1.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

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