How to replace the blank values to NULL for a field in SSIS

  • i have package it import data from flat file in the flat for one field i have blank values i want to replace them by null.

    the destination field is having decimal data type. is it possible to replace blank fields by null, if so how?

  • yes you can do this by using a derived column transformation.

  • can you provide the solution, basically the incoming field has

    0.0

    25.0

    and i want to replace it with NULL

    0.0

    25.0

    NULL

  • sqlbi (9/20/2010)


    can you provide the solution, basically the incoming field has

    0.0

    25.0

    and i want to replace it with NULL

    0.0

    25.0

    NULL

    NULL can have different meaning when it comes to EXCEL and SSIS

    I would advice you to convert all non available fields to some fixed value for instanve say "-1"

    Raunak J

  • sqlbi (9/20/2010)


    can you provide the solution, basically the incoming field has

    0.0

    25.0

    and i want to replace it with NULL

    0.0

    25.0

    NULL

    Add a derived column transformation in the data flow, connect this to the source.

    open the derived column editor then select to overwrite the column with the data and then add some code to do the replace the basic structure is

    REPLACE( «character_expression», «search_expression», «replace_expression» )

  • The easiest solution is to select the Retain null values in the source as null values in the data flow option in your flat file source.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Raunak Jhawar (9/20/2010)


    NULL can have different meaning when it comes to EXCEL and SSIS

    I would advice you to convert all non available fields to some fixed value for instanve say "-1"

    I wouldn't do that. Sure, it works most of the time for strings, but certainly not for numeric data types.

    If you add a -1 for every null value, it will screw up every aggregate that you make. If it remains null, SQL Server doesn't take them in account when creating aggregates.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply