Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 assign value to variable in script task

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-16 : 06:16:39
In scrip task:

DateTime myDate = 10/01/2012 00:00:00
Dts.Variables["myDate"].Value = myDate;

The variable in package is set to be DateTime

In scriptTask editor for ReadWriteVariables, I have : User::ValueDate,User::IndexID

Can you see why I get this below error please?

Error: The type of the value being assigned to variable "User::myDate" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 06:52:10
check the datatype of myDate variable. It should be of datetime type also assignment should be as below

DateTime myDate = "10/01/2012 00:00:00"


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-16 : 07:38:36
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 10:08:38
did it work?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2012-01-16 : 11:59:08
The problem is solved because I had two variables of the same name but different datatypes.
Thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-01-16 : 12:04:29
ok good

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -