I am new to SSIS and having trouble passing parameters to OLE DB Source. I want to query data for a given date range.
I have two variables, variable1 of data type Date Time and the value of the variable is set by expression DATEADD("day", -1, GETDATE())
. variable2 of data type Date Time and the value of the variable is set by expression DATEADD("day", 0, GETDATE())
Inside the OLE DB SOURCE the data access mode is set to SQL command, below is the SQL Code.
Select Col1, col2, col3, col4, coldate where Col1 = 'abc' and coldate between convert(varchar(10), ?, 101) and convert(varchar(10), ?, 101)
I have mapped the parameters as
Parameter0, User::variable1, input
Parameter1, User::variable2, input
When I hit preview, I get an error
"There was an error displaying the preview
Additional Information: No Value given for one or more required parameters. (Microsoft SQL Server Native Client 11.0)"
When I debug the task the error I get is
[OLE DB Source [38]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E21. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E21 Description: "Invalid character value for cast specification".
Note: The datatype for column coldate is datetime
Please help me resolve this issue. I was able to query successfully using data access mode SQL command from variable inside OLE DB Source but I was asked not to use data access mode as SQL command. Thank you.
DATEADD(day, -1, GETDATE())
– Explore