views:

841

answers:

8

I've got some sql returning a decimal(20,0) data type. In SSIS I have a package with a foreach loop. In my variable mappings, what type of variable would I map it to? I've tried Int32, Int64, double, and still get the error "The type of the value being assigned to variable "User::iID" differs from the current variable type..."

+2  A: 

Have you tried Decimal yet?

Joshua
There is no option for decimal or float in the ssis designer
Jeremy
A: 

.NET decimal has methods decimal.ToInt64(), decimal.ToInt32() etc.

Dmitri Kouminov
A: 

A float or a decimal would be my recommendation.

Scott Anderson
There is no option for decimal or float in the ssis designer
Jeremy
A: 

A SQL decimal(20,0) has a precision of 20 which equates to 13 bytes of storage. The .Net decimal is 16 bytes and should work.

hipplar
+1  A: 

SSIS does have Decimal and Numeric types. You can use either of these and it'll go through (except maybe on a Union All, where you should make sure they're the same precision and scale).

See more about data types here.

Eric
Where? In the variables window, I can pick Boolean, DBNull,Double, Int16, Int32, Int64, Object, SByte, String, UInt32, UInt64 but no decimal or numeric
Jeremy
A: 

Clarifying the question: The person asking the question wants to store a value of type decimal(20,0) in an SSIS variable - not a variable in a .NET script, but a variable tied to a package or container, as created in SSIS itself. I have a similar problem....

Then the ".Net" tag on the OP is incorrect...? I'm sure you're right, but...
GalacticCowboy
A: 

You would need to convert the SQL data type to an Int64 prior to putting it into a Int64 package variable.

How are you getting it, as an output parameter?

In a dataflow, you would obviously read it into a decimal/numeric and then convert to Int64 in a Data Conversion component.

If you're trying to directly map an output parameter from an Execute SQL Command task, you'll probably have to use a temporary object package variable and then convert it in a script task into the real Int64 package variable.

Cade Roux
+1  A: 

The SSIS variable designer did not, in my case, show the Decimal or Numeric data types to select to place my decimal(18,2) value into.

I changed my variable to Object, and was able to read the Decimal(18,2) value from the result set of one stored proc, and pass it as a parameter with type Money to a second SP.

So I would use "Object" if you cannot find a type in the variable list that works for you.

Joon