I have a script below that is a stored procedure, now this stored procedure was being called from a SSIS package before. Now I don't want to call it at the SSIS packages, I want to take the script itself and put it on my SSIS package process called Execute SQL Task. The problem I am having is that this stored procedure has variables, and I have never used a script in SSIS packages with variables. How do I go about changing my script to fit on SSIS packages?
What I tried before was not the much since I have no background about variables in SSIS packages. I would love your help on this.
Declare @cmd varchar(max), @dateStart as date, @dateEnd as Date,
@dsTxt as char(10), @deTxt as char(10), @YM as char(6)
set @dateStart = CONVERT(VARCHAR(25), DATEADD(dd,-(DAY(DATEADD(mm, 1, getdate())) - 1), DATEADD(mm, -1, getdate())), 120)
set @dsTxt = @dateStart
set @dateEnd = CONVERT(VARCHAR(25), DATEADD(dd, -(DAY(getdate()) - 1), getdate()), 120)
set @deTxt = @dateEnd
set @YM = cast(year(@dateStart) as char(4)) + case when len(cast(month(@dateStart) as char(2))) = 1 then '0'+ cast(month(@dateStart) as char(2)) else cast(month(@dateStart) as char(2)) end
print @dateStart
print @dsTxt
print @datEend
print @deTxt
print @YM
truncate table tablename1
--delete from dbo.Wasp_CDR
set @cmd = '
insert into tablename1
SELECT *
FROM OPENQUERY (M_yea, ''SELECT column1,column2
From tablename2
where (column1 like ''''SMSZ%'''' or column2 like ''''08%'''')
and column3 = ''''SMS'''' and column4 = ''''MO''''
and to_char(date, ''''YYYYMM'''') = ''''' + @YM + ''''''');'
--print @cmd
exec (@cmd)
I am expecting to find a way on how do i go about scripts that has variables in SSIS packages.