Derived column expression error

Beacon77 131 Reputation points
2022-04-13T18:49:28.29+00:00

Hi All,
I have a derived column task and the expression is ((DT_NUMERIC,16,0)@[User:strETLBatchNbr]). This package when run is throwing the below errors
DRV_ETL_BATCH_NBR [57]] Error: Error code 0x80070057 occurred attempting to convert from data type DT_WSTR to data type DT_NUMERIC.
[DRV_ETL_BATCH_NBR [57]] Error: Casting expression "@[User::strETLBatchNbr]" from data type "DT_WSTR" to data type "DT_NUMERIC" failed with error code 0xC00470C2.
[DRV_ETL_BATCH_NBR [57]] Error: Computing the expression "(DT_NUMERIC,16,0)@[User::strETLBatchNbr]" failed with error code 0xC00470C4. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.
[DRV_ETL_BATCH_NBR [57]] Error: The expression "(DT_NUMERIC,16,0)@[User::strETLBatchNbr]" on "DRV_ETL_BATCH_NBR.Outputs[Derived Column Output].Columns[drvETLBatchNbr]" is not valid.

When I opened the variable it does not have any value nor any expression to evaluate. Please need help

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

Accepted answer
  1. Yitzhak Khabinsky 26,586 Reputation points
    2022-04-13T20:44:36.677+00:00

    Hi @Beacon77 ,

    It seems that the variable in question User::strETLBatchNbr has no value.

    In such case, you can use the following expression:

    (DT_NUMERIC,16,0)REPLACENULL(@[User::strETLBatchNbr], "0")  
    

    You can use any appropriate default value instead of zero.

    UPDATE

    (DT_NUMERIC,16,0)((ISNULL(@[User::strETLBatchNbr]) || @[User::strETLBatchNbr] == "") ? "0" : @[User::strETLBatchNbr])  
    

1 additional answer

Sort by: Most helpful
  1. ZoeHui-MSFT 41,491 Reputation points
    2022-04-14T02:34:13.563+00:00

    Hi @Beacon77 ,

    The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.

    It seems that your source variable is varchar and you are have empty value in that.

    Please share the expression variable with us so that we could do more test.

    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.

    0 comments No comments

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.