I have an Execute SQL Task that is (hopefully) going to receive a global variable called startDate
, which is set to a Date type. A shortened version of the code looks like this:
DECLARE @startDate DATETIME,
@endDate DATETIME
SET @startDate = ?
SET @endDate = DATEADD(DAY, 6, @startDate)
INSERT INTO destinationTable
SELECT *
FROM sourceTable
WHERE startDate = @startDate
AND endDate = @endDate
When I replace the parameter with a date (e.g. '08-01-2012'), the statement parses correctly; however, as soon as the parameter is added back in, the statement errs.
I use DTS very rarely, so I'm basing this code entirely on Microsoft's Using Parameterized Queries. Can anyone enlighten me on how to correctly use a parameter in this situation?
Edit: The error detail reads "Syntax error or access violation" which, considering the circumstances, I assume to read as a syntax error due to the addition of the "?".