Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-11-25
6
Medium Priority
?
193 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
5 Comments
 
LVL 66

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 84

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 800 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 1200 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Lessons learned during ten years of interviewing for SQL Server Integration Services (SSIS) and other Extract-Transform-Load (ETL) contract roles and two years of staff manager interviewing contractors.
My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

824 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