hey guys so i created two variables: startdate and todate and I am attempting to pass them through my SQL query in SSIS and I have added them in my Parameter Mapping but how does SSIS which variable to use after if it sees a third question mark?
for example: so how would SSIS know to use startdate when it inserts into #multileg and not use the todate variable?
e
--Declare @StartDate date
--declare @ToDate date
--set @startdate = dateadd(dd,-10, cast(getdate() as date))
--set @ToDate = dateadd(dd,-9,cast(getdate() as date))
---SSR Table with passenger info, both APAY and PET
create table #SSRData
([ssrfl] int, [ssrcode] char(4), [ssrsequenceid] smallint, [ssrstatuscode]
char(2), [servicestartcitycode] varchar(5),
[ssrstartdate] date, [databasetimestamp] datetime, [pnrlocator] char(8),
[pnrcreatedate] date, [passengersequenceid] smallint,
[namefirst] varchar(250), [namelast] varchar(250), [frequenttravelernumber]
varchar(25)
)
insert into #ssrdata
select distinct ssrfl,
s.ssrcode,s.ssrsequenceid,s.ssrstatuscode,s.servicestartcitycode,
s.ssrstartdate, s.databasetimestamp, s.pnrlocator, s.pnrcreatedate
,s.passengersequenceid, namefirst, namelast,frequenttravelernumber
--into #SSRData
from
(select cast(ssrflightnumber as int)ssrfl,
ssrcode,ssrsequenceid,ssrstatuscode,servicestartcitycode,
ssrstartdate, pnrlocator, pnrcreatedate
,passengersequenceid,databasetimestamp from dwjetblue2.dw.resssr
where SSRCode in ('APAY', 'PETC') and PNRLocator <>'purged'
and ssrstartdate >= ?
and ssrstartdate < ?)s
inner join dw.dw.ResPassenger p
on p.pnrcreatedate=s.pnrcreatedate
and p.pnrlocator=s.pnrlocator
and p.passengersequenceid=s.passengersequenceid
inner join dwjetblue2.dw.ResPassengerFT ft
on ft.pnrcreatedate=s.pnrcreatedate
and ft.pnrlocator=s.pnrlocator
and ft.passengersequenceid=s.passengersequenceid
--MultiLeg
create table #multi
(
[pnrlocator] char(8), [pnrcreatedate] date
,[segmentnumber] tinyint, [marketingflightnumber] char(5)
,[servicestartcity] char(3), [serviceendcity] char(3)
,[servicestartdate] date
)
insert into #multi
select distinct
pnrlocator p, pnrcreatedate d ,segmentnumber s,
marketingflightnumber fl,
servicestartcity sc, serviceendcity ec, servicestartdate sd
--into #multi
from dw2.dw.resflight
where servicestartdate >= ?
Brad's answer is a great way to do it. Another way is to simply add the parameter to your Parameter Mapping a second time.

A third way is to build your SQL statement in a variable with expressions. Then in your Execute SQL Task, your SQLSourceType would be Variable, and then you select the variable that contains your query. This can be an easy way to do it so you avoid messing around with picking the right data types for your parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With