SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Should I create a VIEW or SP to do this?


Should I create a VIEW or SP to do this?

Author
Message
Vertigo44
Vertigo44
Old Hand
Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)Old Hand (384 reputation)

Group: General Forum Members
Points: 384 Visits: 839
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!
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)

Group: General Forum Members
Points: 32541 Visits: 18556
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

Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10120 Visits: 5314
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
Mr Quillz
Mr Quillz
SSC Journeyman
SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)

Group: General Forum Members
Points: 85 Visits: 240
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!!!!
Jayanth_Kurup
Jayanth_Kurup
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2917 Visits: 1351
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
steveb.
steveb.
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4406 Visits: 7195
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
Elliott Whitlow
Elliott Whitlow
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10120 Visits: 5314
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search