Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Should I create a VIEW or SP to do this? Expand / Collapse
Author
Message
Posted Wednesday, July 6, 2011 12:42 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, December 10, 2014 12:07 PM
Points: 219, Visits: 727
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!
Post #1137580
Posted Wednesday, July 6, 2011 1:00 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
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
Post #1137591
Posted Wednesday, July 6, 2011 3:11 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, October 9, 2014 1:02 PM
Points: 6,032, Visits: 5,284
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
Post #1137684
Posted Thursday, July 7, 2011 5:05 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, December 11, 2014 1:49 AM
Points: 60, Visits: 221
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!!!!
Post #1137973
Posted Thursday, July 7, 2011 5:12 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 8:46 PM
Points: 1,786, Visits: 1,015
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
Post #1137979
Posted Thursday, July 7, 2011 5:14 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, May 30, 2014 6:27 PM
Points: 2,808, Visits: 7,175
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
Post #1137981
Posted Thursday, July 7, 2011 10:02 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, October 9, 2014 1:02 PM
Points: 6,032, Visits: 5,284
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
Post #1138256
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse