convert string into integer in ssis

Shambhu Rai 1,411 Reputation points
2022-03-31T14:20:44.907+00:00

Hi Expert,

How to convert string into integer in derived transformation . I may also have some spaces in number. I have target column as integer

Column1
2342

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,344 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2022-03-31T15:44:45.413+00:00

    In a derived column set the expression to something like this: (DT_I4)TRIM(REPLACE(MyColumn," ",""))

    188829-image.png

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2022-03-31T14:51:35.453+00:00

    You'll need to use a custom expression to normalize the data before the conversion. Perhaps something like this (not tested):

    TRIM(REPLACE(myStringColumn, " ", ""))
    

    This would replace spaces in the value with nothing and then trim the string. At that point, if it is a number, then you should be able to convert it. Otherwise it'll error and you're error processing will kick in. If you wanted to handle that as well then your expression would get bigger. At some point though it might be easier to switch to a scripting task to handle the work but I wouldn't start there.

    0 comments No comments

  2. Shambhu Rai 1,411 Reputation points
    2022-03-31T15:02:17.89+00:00

    TRIM(REPLACE(myStringColumn, " ", ""))

    thanks for trim function... could you please help in converting to integer in derived transformation


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.