question

jmb4 avatar image
jmb4 asked

SSIS derived column expression does not accept object type variable...

Hi, I am copying a date from a SQL task into a variable in SSIS. The variable type is system.object. I then need to display the contents of the variable in a derived column in SSIS but the expression does not accept an object type of variable. If I change the type to string or otherwise the select does insert correctly into the variable with the following error: [Execute SQL Task] Error: Executing the query "select GETDATE() " failed with the following error: "The type of the value being assigned to variable "User::dat2" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. ". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. Is there a way to do this?
ssis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image
Pavel Pawlowski answered
Why not set the variable type to DateTime, when assigning DateTime value into it?
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jwelch avatar image
jwelch answered
In the Execute SQL Task where you are retrieving the date, you are probably using a result set type of Full. Instead, use Single Row, which should just put the value of the GetDate() function into the variable. That way, you can use a variable type of string or datetime.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.