Page 1 of 1

Varchar to SmallInt

Posted: Mon Aug 13, 2007 3:37 pm
by Hope
I have a source feild whose datatype is varchar. I have to convert this to SmallInt in Target. What kind of a function I can use in Transformer.
Please suggest.


Thanks

Posted: Mon Aug 13, 2007 3:44 pm
by ArndW
The chapter on conversions should cover that (I don't have it accessible right now) but I am sure that this is one where an implicit conversion will work, i.e. just drag the VarChar column to an appropriately defined SmallInt output column.

Posted: Wed Aug 15, 2007 8:19 am
by krishobby
You can use StringToDecimal(<input port.)

If you want to check before converting you can use the following:

If IsNull(<input port>) Then SetNull()
Else If Trim(<input port>) Then Setnull()
Else Trim(<Input port>)

If you want to check the validity of the data before converting you can also use the IsValid function

If IsValid ("unit32",<input port>) Then StringtoDecimal(<input port>)