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 2005 Forums
 SSIS and Import/Export (2005)
 Problem with Global Variable Datatype

Author  Topic 

Ravi0435
Starting Member

47 Posts

Posted - 2007-05-30 : 12:39:18
hi everyone,
How do i declare a global variable in my package which takes a numeric value like User::VAR1 = 200402 and later on work on it

Later in the properties of the Dataflow i want to have this expression..

"select * from " + "TAB1" + " where Date=" + @[User::VAR1]

Here i want to subtract 190000 from @[User::VAR1] to get it in to myformat i.e the DATE format in the table


I can only see String datatype and othe datatypes wont allow me to to do any kind of manipulation in the expression:
and to be more specific what are
Int16
Int32
Int64
Double

I tried to use all of the above but the expression doesnt allow me as it says:

TITLE: Microsoft Visual Studio
------------------------------

Nonfatal errors occurred while saving the package:
Error at Extract: The data types "DT_WSTR" and "DT_I8" are incompatible for binary operator "+". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.


Any help would be appreciated..

thanks,
ravi


Nothing much that i can do..!!

nr
SQLTeam MVY

12543 Posts

Posted - 2007-05-30 : 13:26:13
Do you know how to cast datatypes? Have a look at the cast operator.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Ravi0435
Starting Member

47 Posts

Posted - 2007-05-30 : 14:04:21
hi,
I tried all type casts....anyways atlast i got it by using....but not before changing my datatype of the variable in the declaration...:

"select * from " + "TAB1" + " where Date=" + (DT_WSTR,20)(@[User::VAR1] - 190000)

thanks though..!!!
ravi





Nothing much that i can do..!!
Go to Top of Page
   

- Advertisement -