Importing CSV file using SSIS spliting into four tables(already in the database)

  • Hello Everyone,

    How's Everyone doing? I hope all is well.

    I have CSV file with a million rows that I need to split into 4 tables(250,000 rows to one table) and I can use your help. I want to use SSIS to upload the CSV file(split 4 ways) into 4 different tables). Can anyone help me with this please; Do I use a conditional split? And if so, what will be the expression written? 

    All ways to do this is appreciated.

    Thanks in advance!

  • I would use a script transform to do the conditional split.

    http://www.sqlis.com/sqlis/post/Using-the-Script-Component-as-a-Conditional-Split.aspx

    Assuming you want to use a round-robin row distribution technique, the code would look like this:

    int rowCounter = 0
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        rowCounter += 1;
        switch (rowCounter % 4)
        {
            case 0:
                Row.DirectRowToOutput0();
                break;
            case 1:
                Row.DirectRowToOutput1();
                break;
            ...
        }
    }


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

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