Solved

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

Posted on 2014-11-25
6
160 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My client has a dictionary table. They're defining a list of standard naming convention. Now, they are requiring my team to provide us a mechanism how to match new incoming data with existing data in their system.
I have a large data set and a SSIS package. How can I load this file in multi threading?
A short film showing how OnPage and Connectwise integration works.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

930 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

15 Experts available now in Live!

Get 1:1 Help Now