Return Record Number with query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CoolRiyaz
    New Member
    • Mar 2007
    • 12

    Return Record Number with query

    I want to return record number with my query output.

    I dont' want to use IDENTITY function and temp table for this purpose as I am dealing with very huge data.


    any suggestions...




    Riyaz
  • Taftheman
    New Member
    • Nov 2006
    • 93

    #2
    Originally posted by CoolRiyaz
    I want to return record number with my query output.

    I dont' want to use IDENTITY function and temp table for this purpose as I am dealing with very huge data.


    any suggestions...




    Riyaz
    Hi can you explain a bit more please

    Comment

    • CoolRiyaz
      New Member
      • Mar 2007
      • 12

      #3
      Originally posted by Taftheman
      Hi can you explain a bit more please

      Suppose my query is :

      SELECT FirstName, LastName, Address FROM EmpMaster

      I want the output like :

      SrNo FirstName LastName Address
      1 asas dfddsf dfdsf
      2 dsfdsfdsf dfdsfdsf dfdfsdf
      3 .... and so on


      I dont want to use temp table and IDENTITY function as data is very very huge.

      Any other solution?


      Riyaz

      Comment

      • iburyak
        Recognized Expert Top Contributor
        • Nov 2006
        • 1016

        #4
        IF you use Server 2005.

        Try this:

        [PHP]select row_number() over (order by ID) as NumberItems, *
        from table_name[/PHP]

        Comment

        • CoolRiyaz
          New Member
          • Mar 2007
          • 12

          #5
          Originally posted by iburyak
          IF you use Server 2005.

          Try this:

          [PHP]select row_number() over (order by ID) as NumberItems, *
          from table_name[/PHP]

          Hi
          sorry,
          I am using SQL Server 2000

          Now tell me what to do.


          Thanks

          Comment

          • iburyak
            Recognized Expert Top Contributor
            • Nov 2006
            • 1016

            #6
            You can't get away without temp table on Server 2000.
            If you want this solution let me know.


            Thank you.

            Comment

            • CoolRiyaz
              New Member
              • Mar 2007
              • 12

              #7
              Originally posted by iburyak
              You can't get away without temp table on Server 2000.
              If you want this solution let me know.


              Thank you.

              I am already having this solution but now its performance issue on huge data.

              Thanks for your inputs


              Riyaz

              Comment

              Working...