Stored Procedure vs direct SQL command in SSIS data flow source

13,633

Yes there are issues with using stored procs as data sources (not in using them in Execute SQL tasks though in the control flow)

You might want to read this: http://www.jasonstrate.com/2011/01/31-days-of-ssis-no-more-procedures-2031/

Basically the problem is that SSIS cannot always figure out the result set and thus the columns from a stored proc. I personally have run into this if you write a stored proc that uses a temp table.

I don't know that I would go as far as the author of the article and not use procs at all, but be careful that you are not trying to do too much with them and if you have to do something complicated, do it in an execute sql task before the dataflow.

Share:
13,633
user1289470
Author by

user1289470

Updated on June 18, 2022

Comments

  • user1289470
    user1289470 almost 2 years

    I'm providing maintenance support for some SSIS packages. The packages have some data flow sources with complex embedded SQL scripts that need to be modified from time to time. I'm thinking about moving those SQL scripts into stored procedures and call them from SSIS, so that they are easier to modify, test, and deploy. I'm just wondering if there is any negative impact for the new approach. Can anyone give me a hint?

  • user1289470
    user1289470 over 10 years
    Thanks! I'm going to do that!
  • marc_s
    marc_s over 10 years
    A properly parametrized query is just as good for performance as a stored procedure - it will also be cached, its executing plan will also be reused - no benefit for stored procedure on this front, I'm afraid....
  • Stefan H
    Stefan H over 10 years
    @marc_s That is correct - there is too much ambiguity in the question to determine if that is the case. So I will correct my answer to read possible performance benefits.
  • Zane
    Zane over 10 years
    Woooooah! I would recommend reading the reading the link that he posted as the source. If your stored procedure is well written that you are not going to have these issues. There are certainly possible benefits to using a stored procedure in an OLEDB source. It's just like anything else in SQL everything has it's use and must be used corrrectly.
  • user1289470
    user1289470 over 10 years
    Thanks for the replies. I read the posts HLGEM pointed out and related posts. Most of the embedded scripts are selects with multiple joins (sometimes across different databases) and sometimes unions. There are no parameters or temp tables involved. When I click "Columns" in the source editor, I can see the columns. From what I read from the posts, I guess I can then use stored procedures safely. Are there any more concerns? I just want to be careful before I take the step.
  • dburges
    dburges over 10 years
    I agree that you can avoid most of the problems with better stored procs, but the OP did ask if there were problems using procs and there are. If you don't know you have to be careful, then you might not be. That's why I said I wouldn't go as far as the author did in saying never to use them.
  • Zane
    Zane over 10 years
    Yeah I was just pointing out that this is much less alarmist about using sprocs and more informative.
  • user1289470
    user1289470 over 10 years
    Thanks for the information. I read the linked article from HLGEM's post and the linked articles from that link. I was not aware about those problems before. Now I'll be very careful in using SPs in my OLEDB sources. Thanks again for all your replies!