Target laod when having diffrent number of column in source tables

  • Hi ,

    In my scenario , I am having last 24 month data in 24 diffrent table .

    In my target table there are 20 column , but in source table column number id variant .

    In some source table column count is 19 in some 17 and in some 18 .

    I have to load all 24 table for history load in my target table .

    I am thinking to load using stored procedure , but dont know hows to handle it with diffrent number of source column.

  • vipin_jha123 - Friday, December 15, 2017 5:17 AM

    Hi ,

    In my scenario , I am having last 24 month data in 24 diffrent table .

    In my target table there are 20 column , but in source table column number id variant .

    In some source table column count is 19 in some 17 and in some 18 .

    I have to load all 24 table for history load in my target table .

    I am thinking to load using stored procedure , but dont know hows to handle it with diffrent number of source column.

    Handle it in code.
    And that's about as specific as I can be, since you did not provide DDL, consumable sample data and desired output.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • You can use below table script and can insert any test value for test
    cREATE TABLE TAB1
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    phase    varchar(MAX),
    )

    cREATE TABLE TAB2
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    Region    varchar(MAX)
    )

    cREATE TABLE TABTARGET
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    dphase    varchar(MAX),
    Region    varchar(MAX)
    )

  • vipin_jha123 - Friday, December 15, 2017 6:10 AM

    You can use below table script and can insert any test value for test
    cREATE TABLE TAB1
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    phase    varchar(MAX),
    )

    cREATE TABLE TAB2
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    Region    varchar(MAX)
    )

    cREATE TABLE TABTARGET
    (

    URN    bigint,
    eno    varchar(MAX),
    Schoolname    varchar(MAX),
    dphase    varchar(MAX),
    Region    varchar(MAX)
    )

    What is the goal here?  Load all of TAB1 into TABTARGET, then load all of TAB2 so you have nulls is some rows for phase and region?  Join TAB1 & TAB2 then insert the product into TABTARGET?  If the latter what is the relationship between TAB1 & TAB2

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

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