pass datetime variable into execute sql task which has stored procedure
Hi all
I have a stored procedure something like this exec sp_name startdate, enddate. I have to run this in an ssis package.
The startdate and enddate values are loaded from a sql query, so i have declared variables (startdate,enddate) and got those values from the query using evaluateasexpression. Now, when i call the stored procedure in execute sql task it fails as the datatype
from the variable is string and the stored procedure parameter (startdate,enddate) are datetime. Please help me.
The following are my settings in execute sql task editor
SQL statement : EXEC sp_name ?,?
parameter mapping
variablename: user::startdate
Direction: Input
data Type: Date
Parameter name : 0
Parameter size : -1
April 8th, 2011 10:59am
What is the data type of the variables startdate and enddate? Make them string and set the data type as VARCHAR in execute sql task editor.Nitesh Rai- Please mark the post as answered if it answers your question
Free Windows Admin Tool Kit Click here and download it now
April 8th, 2011 11:18am
Hi Nitesh
The data type for startdate and enddate is datetime. I have done what you have mentioned ealier but still get the following error
[Execute SQL Task] Error: Executing the query "EXEC sp_name ?, ?" failed with the following error: "Error converting data type varchar to datetime.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not
set correctly, or connection not established correctly.
April 8th, 2011 11:24am
so i have declared variables (startdate,enddate) and got those values from the query using evaluateasexpression.
did you fetch used an execute sql task for each of startdate and enddate values?
what do you mean by evaluateAsExpression in startDate and endDate variables?! they should be exact date values, and this means that you should fill them with execute sql tasks before calling exec sp_name in last execute sql task.
Does it make sense to you?http://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
April 8th, 2011 2:14pm
What is the date format? Make it yyyy-mm-ddNitesh Rai- Please mark the post as answered if it answers your question
April 8th, 2011 2:39pm
Hi Reza and Nitesh
Thanks for the replies. I figured out a complete different approach by creating variables startdate and enddate as datetime and then used EXecute sql task to run the sql query which gets the startdate and enddate then set the ResultSet to Single row and
finally in the Result Set editor set the column names of the query for Result Name to startdate and enddate variables respectively.
So the Execute sql task looks like this
General
Resultset : Single Row
Result Set
Result Name Variable Name
Start_Time user::Startdate
End_Time user::Enddate
Thanks
Free Windows Admin Tool Kit Click here and download it now
April 8th, 2011 4:21pm