Solved

sending parameter values into "Data Flow Task: Source SQL Command."s

Posted on 2014-11-25
6
156 Views
Last Modified: 2016-02-11
the SSIS package has many [Data Flow Task: Source SQL Command.} elements in sequence. (157 to be specific)

The source has these different kind of WHERE conditions used at the moment.

Select * from ____ where a in (,,,,,) and b in (,,,,,)
Select * from ____ where a in (,,,,,)
Select * from ____ where b in (,,,,,)
Select * from ____ where c in (,,,,,)
Select * from ____ where b in (,,,,,) and c in (,,,,,)

Right now they are all hard coded.. if I want to move them to parameter variables (SSIS->Variables), can you suggest how this can be done?

my dilemma is that

Select * from ____ where a in ? and b in ?
won't work for both
Select * from ____ where a in (,,,,,) and b in (,,,,,)
and
Select * from ____ where b in (,,,,,) and c in (,,,,,)

Thank you,
0
Comment
Question by:25112
6 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40465189
Give us a data mockup of what you're trying to pull off here.
0
 
LVL 5

Author Comment

by:25112
ID: 40465230
right now every query in the sources are hard coded with the values. but if the values in the hardcode is to be changed, then all 157 tasks have to be touched.
but if parameters can be used, then it should be totally customizable on a quick notice, but then the parameters are different for for 2 different tasks.. one of them has one parameters.. another has two.. but among the 157, you have only 5 kinds/types/categories of WHERE Conditions.
0
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 200 total points
ID: 40521784
place your variables at the top of the file.  http://msdn.microsoft.com/en-us/library/hh213296.aspx
and reference the parameters in your code.
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 300 total points
ID: 40521792
Hi,
are these 157 data flows reading from the same source and writing to the same targets (hence is the data flow structure identical for all of them - just the selection criteria / filter is different)?

If the answer to the above question is YES, then I would normally go that route:
- Create a table to store the filter conditions with the following columns
  a. ID
  b. Filter Name (could be handy for logging/debugging)
  c. Filter Type (for each filter type combination a dedicated value e.g. A, B, C, AB, AC,BC )
  d. FilterField A Filter value
  e. FilterField B Filter value
  f. FilterField C Filter value
  g. If necessary perhaps a SortOrder field
- Query the filter table and use a foreach loop inside the control flow to loop through each filter
- Either use an expression (using IF statements on the filter type) OR a script component to build the complete WHERE statement based on the information from the current filter record
- In the single generic data flow inside this foreach loop use a variable as data source where you use the standard select statement and the where expression you built upfront

Perhaps there are better alternatives but IMHO a quick and extendable solution.

HTH
Rainer
0
 
LVL 5

Author Comment

by:25112
ID: 40543587
thanku
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now