Reputation: 434
I'm new to SSIS so forgive me if this question is trivial or has already been answered. So I have a SQL query that begins as follows:
declare @start datetime, @end datetime, @startMonth datetime, @endMonth datetime, @maxHoursToRespond int
----Set These------------------------------------------------
set @end='6/27/2014'
set @maxHoursToRespond=24
-------------------------------------------------------------
set @start=dateadd(dd, -90, @end) -- set duplication period
set @startMonth=dateadd(dd, -2, @end)-- set to start date of output you want
set @endMonth=dateadd(dd, -1, @end) -- set to day of end date of output you want
When I put this in my OLE DB Source Editor with SQL command as my data access mode, all the variables are replaced with question marks. It looks like :
DECLARE ? datetime, ? datetime, ? datetime, ? datetime, ? int
/*--Set These------------------------------------------------*/ SET ? = ?
SET ? = 24
/*-----------------------------------------------------------*/ SET ? = dateadd(dd, - 90, ?)
SET ? = dateadd(dd, - 2, ?)
SET ? = dateadd(dd, - 1, ?)
In the query builder.I'd like to know why this is happening.I'd also like to know how I can allow the query to be successfully built (currently I get a syntax error of "The Declare SQL construct or statement is not supported."). Do I have to create these variables (like @start) in SSIS itself?
Upvotes: 0
Views: 1689
Reputation: 2768
I have pasted straight to SQL command text
yours script in OLE DB Source Editor
and nothing changed in it. By pressing Parse Quesry..
I checked that SQL is correct. When I tried to use Build Query..
, it said, that DECLARE
is not supported. So don't use builder :)
Upvotes: 1
Reputation: 2565
You can:
EXEC My_Stored_Procedure
Exec My_Stored_Proc ?,?,?,?
with the user variables mapped to the corresponding stored procedure variables.Number 2 is the generally accepted method, unless you store your variable values in a table or something that the SP in number can access, in which case number 1 may be cleaner.
Upvotes: 1