• ammit.it2006 (7/2/2016)


    I also tried something similar..............:-P

    select ROW_NUMBER() over(order by id) , name From Table1

    union

    select ROW_NUMBER() over(order by id) +3, name From Table2

    Unfortunately, that presupposes the esoteric knowledge that you have 3 items in Table1. Not exactly flexible code.

    Also, since there is the possibility of duplicates between the two tables, the use of UNION could return incorrect results.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)