Dynamic ETL with SSIS

  • Nice article. Any thoughts on doing the reverse, dynamically exporting data to tab-delim or csv files? I support an MDM db with application specific views. Occassionally we have to export the view results to flat files for ftp outside the organization. I'd like to develop a single SSIS pkg that would create the export files based on the view columns.

  • You can export data directly from a stored procedure by using xp_cmdshell and running a bcp command on the operating system.

  • This is a great article! I am facing a very similar task right now and will certainly use many of these ideas. One request. If it's not too much trouble, please provide an SSIS leveraging this approach (the screen shots are in the article by an actual .dtsx would be helpful).

    Thank you!

  • I believe you could use this approach for exporting as well. You would be going back the other way in terms of concatenating all your fields together and then dumping them into the flat file into the "everythingelse" field so that SSIS could pick up the flat data. You would still want to create some sort of dictionary but it might mainly be used for converting the fields to varchar/nvarchar so that they could be concatenated. You also may need to create some special functions for concatenating based on fixed length versus delimited. If you created your business tables that mapped exactly to the fields you wanted to export, getting them concatenated into the Load_* tables wouldn't be too bad. Then your SSIS package would read the criteria of which table to pick up and export that. File names could be generated using information in the database.

  • I have added the DTSX file to the article if you are interested in viewing Sarah's work.

  • can you tell me how to create bulk like that

  • i am new with this

    can you explain me if

    i have dynamic file like 123.txt ,456.csv and like that and want to load them in to sql server

    How can i achive that.??

  • If you have a question about something not in the article, please start your own thread in the SSIS forum.

  • While testing I see a couple of items missing:

    Msg 208, Level 16, State 1, Line 1

    Invalid object name 'RN_UPD'. (RN_UPD Table is Missing)

    Msg 208, Level 16, State 1, Line 2

    Invalid object name 'dbo.Load_RN'. (Load_RN Table is Missing)

    Msg 208, Level 16, State 1, Line 2

    Invalid object name 'dbo.GetNextWednesdaysDate'. (GetNextWednesdaysDate SP is Missing)

    Can you please add it? thanks!

  • The Load_RN table is referenced in a previous post comment.

    The function is purposely missing as mentioned in the article because you may want to calculate your own date.

    The RN_Upd table doesn't exist because this really needs to be formatted to the data dictionary of your file.

    Hope that helps.

  • I see Load_RNFile in previous comments not Load_RN.

  • yes, these are the same. The Load_* tables are supposed to have the Id, EverythingElse fields but the naming can be arbitrary because you would want one for each file. Also you would want one table for the parsed output per file. Sorry for the misnomer in the example, hope that helps you.

  • Excellent article. This is similar to something i have previously developed whilst working for a company which processes 10 - 1000's of data files daily.

    having the information in the database made it so much easier to process and create new imports.

    the one thing we didn't have was detailed info from our suppliers, we had to work this out and make loads of assumptions too.

    we also had the added problem of managing excel files along with text format files.

  • Thanks for sharing your success story. I like that in the end you got a working solution that serves your users and your company well. That's what we do.

    While I appreciate the result, I would have gone about it differently. From my perspective many of the efforts duplicated what SSIS does for us for free, namely the file parsing. Also worth noting, once you move file parsing into the database you gave up the option for doing data cleansing, validation, multi-system data enrichment, lots of things, in the SSIS space. I realize that sometimes we go with what we know, but SSIS was built to do this kind of work, and dynamically too. I think a lot of folks consider using tools other than T-SQL when the task seems to stretch the limits of what T-SQL should be doing, but when it gets to a point where they just need to get something done they revert to T-SQL because that is what is comfortable to them. Crutches like xp_cmdshell (as one poster mentioned, not your article) make it easier to do that as well and point to that type of thought process. I applaud your use of SSIS to at least avoid accessing the cmd prompt and file system from within T-SQL, something I never condone.

    Here is a technical paper from Microsoft explaining how to do everything in SSIS:


    I know not everyone will sign up for a pure SSIS solution but something along these lines is how I would have solved this problem. Granted, i have .NET development skills which are required for putting together the solution described in the paper and not a lot of DBAs do, nor is the technology a good choice in all shops because of that same fact. Someone has to support the code too, so that has to be considered as well.

    There are no special teachers of virtue, because virtue is taught by the whole community.

  • Thanks Sarah, your article is very intersting and gave me some ideas. I can't wait to play around with this. Most of my business data comes from vendor flat files, mostly fixed width, with anywhere from 50-400 fields. Data dictionaries or layout guides are usually available, although the vendors don't usually notify me when making format changes. Fun!

    You are right, it is much simpler to use the database for transformations and logic. Thanks for explaining how to store and use the data definition and import criteria there. SSIS is generally slow and frustrating for testing and troubleshooting my wide files. Your solution is also one I can afford on my shoestring IT budget!

    I use the field name and width with the concatenate function in Excel to quickly make the fields section of a script for a raw import table, then paste that into my SSMS script. A quick way to make fields in SSIS is to use BIDS Helper (free, available on CodePlex). I copy the field name and width and paste it into the BIDS Helper "Create Fixed Width Columns" window. These two things have saved me days of work during testing of a new vendor format.

Viewing 15 posts - 16 through 30 (of 34 total)

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