Flat file source with varying number of columns - help needed

  • I'm using SSIS 2008 to import a CSV file into my SQL sever 2008 database.

    The CSV file comes from an external source once a week. It is created from a table at the source. I know the names of all the columns in that table. The columns in the CSV file will be a subset of the columns in that table. However the columns in the CSV file in any given week will vary. i.e., it is not possible to predict which combination of columns will be in the CSV file each time it is received. I would like to be able to import whatever columns are in the file each week into my database. Whatever columns are missing each week can be left NULL in my table.

    The problem is, if I set up a flat file source and map all the possible column names from the CSV into my database, at execution time if a column is missing the package will execute without error messages but no rows are transferred into my table.

    If I run a test that does have all the columns present, the rows get transferred.

    I would be grateful if someone could suggest a way to insert the rows, even if a column is missing at execution time. The rows can have a NULL value for whatever column is missing.

  • Sounds like you might have to consider a custom source using a script component with either VB or C#.

    The source needs to output every column you have in your table(s). For every column that is not in the input file, the custom source should set the output to the required "null" value'.

    Sounds pretty simple, as long as you know what the columns are in your input file.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

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

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