Reputation: 459
In the Lookup Transformation , I specify a reference data set to use as follow:
SELECT DISTINCT Client_ID
FROM dbo.CLIENT
WHERE (ENROLLMENT_DATE >='2016-07-01') AND (DE_ENROLLMENT_DATE <='2017-06-30')
If I want to replace the hard-coded '2016-07-01'
and '2017-06-30'
, does anyone know how I can do it? Thank you for your help.
Upvotes: 4
Views: 2920
Reputation: 11188
Before your Lookup Transformation add a Derived Column Transformation, in this create two new columns to get the month and year from a date variable. Like so:
In your lookup transformation use the following query:
SELECT
Client_ID
,YEAR(ENROLLMENT_DATE) AS ENROLLMENT_YEAR
,MONTH(ENROLLMENT_DATE) AS ENROLLMENT_MONTH
FROM CLIENT
Then in the Columns page of your Lookup Transformation wire up your query like so:
I don't think you need DISTINCT in your query because the Lookup Transformation just returns the first row that it finds.
Upvotes: 2
Reputation: 37313
You can use expressions to achieve this, just follow these steps:
@[User::strBeginDate]
and @[User::strEndDate]
) of type stringDataFlow Task
and press F4
to show the properties Tab[Lookup Transformation].SqlCommand
Use the following expression
"SELECT DISTINCT Client_ID
FROM dbo.CLIENT
WHERE (ENROLLMENT_DATE >='" + @[User::strBeginDate] + "') AND (DE_ENROLLMENT_DATE <='" + @[User::strEndDate] + "')
Upvotes: 4