Add Multiple flat file in SQL

  • Hi

    Want to make SSIS package

    it will take file from folder and insert that file's data in SQL server

    every day in folder i receive different type of file like 1.txt, 2.csv, 4.xml

    i just wnat to send data to sql and in that it has to create table like

    table 1

    table 2 i mean name of file as a table name so every file need to create table and is having different schema on that

    can you help me how to achive this??????

  • SSIS can't handle this to my knowledge.

    What you're going to look to do is build a generic table with a VARCHAR(MAX) field in it, and use that as your original data dump location. Whatever the file is, just dump each row in wholesale into this table.

    Now, you'll start a series of detection procedures you'll have to build yourself to detect the type of file, and then what to do with it. You're going to basically be creating a file importer from scratch. It's not easy and is going to take a lot of time.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • shirishjani (11/10/2010)


    Hi

    Want to make SSIS package

    it will take file from folder and insert that file's data in SQL server

    every day in folder i receive different type of file like 1.txt, 2.csv, 4.xml

    i just wnat to send data to sql and in that it has to create table like

    table 1

    table 2 i mean name of file as a table name so every file need to create table and is having different schema on that

    can you help me how to achive this??????

    I think this is possible to do, but the solution will vary in level of difficulty depending on if each of the different file types have different numbers of columns or different column names. If the column names and number of columns is static, then I think the solution becomes a lot easier.

    You will need to take the filename that gets captured in a ForEach loop variable and use that in a create table and insert into table statements.

    Take a look at this article for ideas:

    http://www.rafael-salas.com/2009/05/ssis-foreach-loop-looping-through.html

  • @tmitchelar,

    I agree with you it's possible, but the 4.xml statement was the one that got me. He's overloading the load with multiple types, which is gonna go ugly. 🙂

    The biggest problem he'll have is that the metadata can't be updated at runtime, only design-time. Between that and the fact that he stated these will come in with different schema led me away from even suggesting a script to detect file type structures to use multiple data flows. He's going to need a complete alternative to SSIS for this as far as I know. It just doesn't want to do it.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Craig Farrell (11/10/2010)


    @tmitchelar,

    I agree with you it's possible, but the 4.xml statement was the one that got me. He's overloading the load with multiple types, which is gonna go ugly. 🙂

    I equally agree with you! Although possible, he's probably looking at lots of dev time even if he's proficient in VB. I wouldn't want to be in his shoes!

  • Suppose i have file name and table the can i achieve that

    i mean i have table there now

    Supposse i have file 123.txt i need to insert that in to table which is ready named 123

    i have another file 456.csv to table 456

    can i achive that?

  • My answer will provide roughly as much detail as your question.

    Yes.

    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.

  • If from folder i take file one bye one

    suppose

    1 is jann.txt then i have that table for that schema is ready so just want to insert in table named jann

    2 sss.csv then insert in to table which is already there name sss

    Like that

    I mean by looking on file name i want to insert then in specific table(which are already there in database) dynamically

    Can i achieve that?

  • shirishjani (11/11/2010)


    If from folder i take file one bye one

    suppose

    1 is jann.txt then i have that table for that schema is ready so just want to insert in table named jann

    2 sss.csv then insert in to table which is already there name sss

    Like that

    I mean by looking on file name i want to insert then in specific table(which are already there in database) dynamically

    Can i achieve that?

    Do columns change or are they always the same?

  • different file has different column and different table destination

  • Do you know what the file definition will be for each table ahead of time?

  • yes like my table are ready

    just reading file name and transfer data to particular table

    like if file name is sss.txt transfer to table name "sss"(this table is already exist in Db)

    and go to read next file read name and again look for particular table belongs to that

  • I would loop through your files and use presedence constraints to determine which table to write to.

  • tmitchelar (11/11/2010)


    I would loop through your files and use presedence constraints to determine which table to write to.

    If I understood the situation correctly, this is the approach I would take. Have a predefined data flow for each possibility and use expressions in the precedence constraints to determine which data flow to execute.

    Looks like we have 2 votes for the same solution.



    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 14 posts - 1 through 13 (of 13 total)

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