skip 1 column from generation

I got a table with say 3 columns I want to generate 2 columns and leave 1 unchanged is that possible
Tagged:

Best Answer

  • Kurt_MKurt_M Posts: 29 Bronze 1
    Accepted Answer
    Hi @TheHartz,

    Apologies for the delay. 

    There's a possibility you can make use of the "Use Existing Data Source" when populating data. Essentially, it works by selecting the data from another table to populate the table you have selected, for the purpose of not overwriting the data you want to keep. This means you have to create a second table with the same data that's in the first table. 

    The reason you'd have to do this, is because if you stay with the normal option of generating data, it will delete/truncate the already existing data. The way I have suggested allows you to populate the columns that would otherwise be overwritten to NULL, with the data from the duplicated table. 

    In my instance I have 2 separate tables, lets call them Table1 and Table2. I have duplicated the data from Table1 into Table2, and on the generator, I have specified that I wish to pull the data from Table2. This then allows me to specify in column 3, that I wish to insert the data from the Table data. The other 2 columns can then have their data generated as per normal.





    active_flg is the column I wish to remain using the data that's already in there. house_id and house_desc is something I'll let the generator create.

    Here is the documentation for this:
    https://documentation.red-gate.com/sdg/using-existing-sources/mapping-sql-tables-or-views


    Kind regards,

    Kurt McCormick
    Product Support Engineer, Redgate

    Need help? Take a look at our Help Center

Answers

  • Hi @TheHartz,

    You can make use the of the "Use Default Values" option. Select the column in question and then choose this option in the drop down.


    Kind regards,

    Kurt McCormick
    Product Support Engineer, Redgate

    Need help? Take a look at our Help Center

  • TheHartzTheHartz Posts: 4 New member

    I Think I was not clear enough, what I intended to was to keep the old data, I’ve tried this but het result is the default data in this case NULL and I want to keep the original data value

  • TheHartzTheHartz Posts: 4 New member
    Kurt_M said:
    Hi @TheHartz,

    Apologies for the delay. 

    There's a possibility you can make use of the "Use Existing Data Source" when populating data. Essentially, it works by selecting the data from another table to populate the table you have selected, for the purpose of not overwriting the data you want to keep. This means you have to create a second table with the same data that's in the first table. 

    The reason you'd have to do this, is because if you stay with the normal option of generating data, it will delete/truncate the already existing data. The way I have suggested allows you to populate the columns that would otherwise be overwritten to NULL, with the data from the duplicated table. 

    In my instance I have 2 separate tables, lets call them Table1 and Table2. I have duplicated the data from Table1 into Table2, and on the generator, I have specified that I wish to pull the data from Table2. This then allows me to specify in column 3, that I wish to insert the data from the Table data. The other 2 columns can then have their data generated as per normal.





    active_flg is the column I wish to remain using the data that's already in there. house_id and house_desc is something I'll let the generator create.

    Here is the documentation for this:
    https://documentation.red-gate.com/sdg/using-existing-sources/mapping-sql-tables-or-views



  • TheHartzTheHartz Posts: 4 New member
    Thats wat i ment. Thnx a lot
Sign In or Register to comment.