Should I create a VIEW or SP to do this?

  • I have copied a third party COLBAL database table by table into sql server. However, the data I need to feed in a txt file resides in many different tables. So I just wanted to get advice on what my choices are...

    1. Use SSIS UNION ALL and join all the tables/OLEDB Sources within SSIS and the output all the required fields to a flat file .txt?

    2. Create a VIEW in the SQL DB that contains only the fields I want. Can I even use a VIEW as an SSIS Data Source? Do views get auto updated? Would a SP come in handy here?

    3. Skip copying the Cobal database to SQL Server and just use SSIS to connect directly to the Colbal database and select only the fields I need to create my output file?

    Thanks!

  • I like option 2 in this case. You can query the view and return the results you need. With the view, it gives you the option to use that view in several procs without having to rewrite the same code over and over.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Not a fan of option 1, better to let the database engine do the heavy lifting..

    Option 2 is a better option especially if you might need to reuse the structure. Views do not get updated at all, because they don't contain any data, they are effectively a named and stored query that can be referenced by other objects. Unless you have created an index on the view then the data in the query is not stored. However the crux of your question is when the underlying data changes does the output of the view change, and the answer is YES.

    Option 3 may work but you have other hurdles such as what middle ware you are going to use to make the connection and such. This options has the most unknowns for me, so I am not a fan.

    CEWII

  • Good Day,

    I would go with Elliott Whitlow on this one.

    I think it's important that we dont leave out the ultimate goal. Which is to eventually dump the data into a ".txt" file. SSIS is your best option to achieving this goal.

    Also you want to manipulate (Transform) the data before dumping it into the destination (".txt") file. Again SSIS is great at doing this.

    But the important decision here is whether you want to use the functionality (the manipulation part of the data) in other instances (objects) or not. If so, you are better off using Option 2, if not, option 1 is the best solution (Also note that option 1 is re-usable as well ;-)).

    Option 3 is a NO, NO!!!!

  • Option 2 is not only easier to implement but also more robust as a solution. Use schema binding on the view to make sure future changes are caught properly. The View fetches committed data on the underlying tables and will give the latest available data at the time the package execute the DFT.

    Check if you would require indexed view and filtering on the underlying data, since this you coul generate a txt file with either a full dump of data or deltas?

    Jayanth Kurup[/url]

  • I would go for Option 3, depending on what type of database is used, as this cuts out all the middle work and will be easier to maintain

  • steveb. (7/7/2011)


    I would go for Option 3, depending on what type of database is used, as this cuts out all the middle work and will be easier to maintain

    While I agree it cuts out the middle man, and that is a good thing, the entire premise is predicated on what drivers are available for the underlying database, provided there actually is one. If it were Postgre, MySQL, DB2, Oracle, and such I might consider this, absent that information I still hold to option 2. My 0.02..

    CEWII

Viewing 7 posts - 1 through 6 (of 6 total)

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