Answer recommended by moderator
Maybe such a query will work as well:
select *
from ...
where [User::InitialorMonthly] == 'Initial'
or ( [User::InitialorMonthly] == 'Monthly' and conditions based on [ModifyDate] )
![]() |
VOOZH | about |
For instance...
If [User::InitialorMonthly] == 'Initial'
SELECT (Everything)
ELSE
SELECT Based on [ModifyDate] being from the 15th of last month to now...[User::InitialorMonthly] == 'Monthly'
I could CASE it out in my T-SQL but if I've already derived it.......why can't I use the SSIS Variable to determine which T-SQL to run?
Hi Bobby P,
Following up to confirm if the earlier responses addressed your query. If not, please share your questions and we'll assist further
Thanks,
Lakshmi
Hi Bobby P,
Following up to confirm if the earlier responses addressed your query. If not, please share your questions and we'll assist further
Thanks,
Lakshmi
Answer recommended by moderator
Maybe such a query will work as well:
select *
from ...
where [User::InitialorMonthly] == 'Initial'
or ( [User::InitialorMonthly] == 'Monthly' and conditions based on [ModifyDate] )
AI answer
Yes. Use the SSIS variable to supply either:
Because the OLE DB Source cannot branch logic itself, the choice of which query to run must be made outside the component and then passed in.
Two common patterns:
User::SqlToRun.User::InitialorMonthly, e.g.:
InitialorMonthly == "Initial" → "SELECT ...""SELECT ... WHERE ModifyDate BETWEEN ..."User::SqlToRun.? placeholders.? to SSIS variables (date range, flags, etc.).User::InitialorMonthly.If the logic truly requires different SQL shapes (different WHERE clauses, joins, etc.), pattern 1 (SQL command from variable) is the usual approach in a Data Flow.
References: