Sunday, March 25, 2012

Derived Column can't add 8-byte integers

I'm having trouble adding a 4-byte integer with an 8-byte integer. Here's what I'm doing:

Column Name: BIG_ID

Derived Column: < add as new column >

Expression: (DT_I8)[ID] + 840230000538058

Data Type: eight-byte signed integer {DT_I8]

The error I get:

The literal 840230000538058 is too large to fit into type DT_I4. The magnitude of the literal overflows the type.

Then I try the expression:

(DT_I8)[ID] + (DT_I8)840230000538058

and

[ID] + 840230000538058

and get the same error.

What am I doing wrong? Is it possible to add 2 8-byte integers in regular expression? Why does it still think the literal is DT_I4?

Thanks,

Michael

I'm able to make this work by putting the large integer into a variable that's been typed as Int64. However, I'm still curious as to why I shouldn't be able to do this in the derived column transformation without using a variable?

Thanks,

Michael

|||Looks like a bug to me. I get the same behavior. Maybe someone from MS could check, or one of the MVPs could flag this for follow-up.|||

When you specify a numeric literal in an expression, it is by default typed as a DT_I4. If you want it to be a DT_I8, you must append an 'L' to the literal. For DT_UI8, append 'UL'.

So for your example, you should try the following expression: (DT_I8)[ID] + 840230000538058L

See the Books Online topic "Literals (SSIS)" for more details.

Thanks

Mark

|||Doh! That would explain it Smile|||

Thanks!

-Michael

No comments:

Post a Comment