how to write Insert stmt by resolving mapped values in another table

  • I have 3 Table say TableA(holding data) ,TableB(mapping data) and TableC(data to be inserted).

    TableA

    Col1 Col2 Col3

    -------------------------------

    High Other1 Other11

    High Other2 Other22

    Low Other3 Other33

    Right Other4 Other44

    Low Other5 Other55

    Left Other6 Other66

    TableB

    Col1 Col2

    -----------------

    1 High

    2 Low

    3 Left

    4 Right

    TableC

    Col1 Col2

    ---------------

    1 Other11

    1 Other22

    2 Other33

    4 Other44

    2 Other55

    3 Other66

    My Dataset is like 3 tables shown above.

    TableA consists of source data uploaded using bcp.

    TableB is a mapping table with static reference values as you can see.

    TableC is the table to which now data has to be inserted which is col1 of TableB and equivalent numeric value for Col1 in TableA.

    So my doubt is how I write so that I write my insert script for TableC

    and resolve corresponding values for Col1 in TableA.

    in short I want numeric equivalent of Col1 in TableA to be inserted into TableC by checking on mapping values rom TableB along with Col3 from tableA(Col3 from TableA is going to be copied as it is to TableC).

    Thanks in advance

  • Hmm. seems like I just answered this question over at the MSDN forums...

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

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

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