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.....

  • Duplicate posting. It was answered here:

    http://www.sqlservercentral.com/Forums/Topic633424-338-1.aspx

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Am using SQL 2000

  • As I mentioned in the other thread, with SQL 2000, there isn't a really easy way to do this. You could insert the results into a temp table or table variable that has an identity column.

    Could you maybe post the query and then show us what you want the output to look like?

    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