Reading from a New table

  • Hi

    I Have an existing table employeeSmall

    create table employeeSmall

    (

    emp_id varchar(10),

    salary varchar(10),

    Misc1 varch(50),

    Misc2 varch(150)

    )

    A New table has been designed employeeLarge which stores all the Misc1 and Misc2 into Misc

    create table employeeLarge

    (

    emp_id varchar(10),

    salary varchar(10),

    Misc varch(500),

    employeeMisID varch(5)

    )

    My old code inserted data into employeeSmall table

    Now the new code inserted the data in employeeLarge table.

    while reading the employee details i should consider reading from the new table employeeLarge first and if there is no record then i need to read from the old table employeeSmall

    Could you help me the best way of doing this...

    Thanks

    Subha

  • Use Exists (T-SQL)

    See: http://msdn.microsoft.com/en-US/library/ms188336(v=SQL.90).aspx

    HTH,

    B

  • Even easier... use MERGE and migrate everything from the old table to the new table so you do't have to do this check for future inserts, etc.

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

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

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