Rownum against each row

  • I have a function GenRows() which generates row nums, and I have a table with 1000 rows, Tab A.

    Syntax: Select RowNum from GenRows(1000) - Generates row nums

    Syntax: Select c1, c2, c3 from Tab A

    Here I need to attach each row num against each row in the final resultset.

    Unfortunately, the function I am using is a Table Inline view, which returns table with row num values and I don't have any matching column between GenRows (which wouldn't obviously being a function).

    I just need a resultset looking like

    RowNum C1 C2 C3

    1 A B C

    2 C A B

    3 B C A

    Can somebody help me on how to resolve this, so that I can have peaceful weekend . Thanks in advance!


    Thanks!

    Viking

  • try this:

    SELECT identity(int,1,1) as rownum, c1,c2,c3 into #temp from tab a

    SELECT * FROM #temp

     

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

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