(DT_I4)"abc"==(DT_I4)"abc" ? 1 : 0 in ssis giving NULL

Chakri. N 1 Reputation point
2022-08-03T06:42:18.193+00:00

It is giving NULL . Can i know the exact reason and how can i rectify it

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,705 questions
{count} votes

3 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,496 Reputation points
    2022-08-03T06:46:44.59+00:00

    Hi @Chakri. N ,

    May I know what the value of the column "abc" so that we could do some local test.

    I did some test, if the column contains null value, it will return NULL like shown below.

    227581-image.png


  2. Olaf Helper 47,516 Reputation points
    2022-08-03T07:11:19.087+00:00

    It is giving NULL

    What else do you expect for a formula like

    (DT_I4)"abc"==(DT_I4)"abc" ? 1 : 0 in ssis giving NULL

    Converting a string literal "abc" to DT_I4 = integer 4 byte will always fail.


  3. ZoeHui-MSFT 41,496 Reputation points
    2022-08-03T09:42:52.37+00:00

    Hi @Chakri. N ,

    DT_I4---A four-byte, signed integer.

    "abc" is a string in SSIS might be DT_WSTR.

    You cannot convert DT_WSTR to DT_I4. It will thrown error like below.

    227664-image.png

    If you configured the error output to ignore the failure, it will return NULL in the result.

    227607-image.png

    I'd like suggest that you may add a new Derived Column to replace NULL to 0 as you need.

    REPLACENULL([New Column 1],0)  
    

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


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.