Replacing blanks with Null through a transfer

  • I am bringing over some data from an AS400 file and there data contains one char as a blank when it is transfered over into MSSQL.

    If it was only a few columns I would be able to handle this, but there are a large amount of columns were this exist and I need to correct it. Any suggestions are welcomed!

    -JG


    -JG

  • 1) In the Transformations tab of DTS properties. Double click on the line from the column that you want to transform to nulls. This should bring up a VB Script.

    2) In the VB Script entry form do the following (replace SrcCol w/ your source column name and DestCol w/ the destination column.

    if isnull(DTSSource("SrcCol")) = True Then

    DTSDestination("DstCol") = null

    else

    DTSDestination("DstCol") = DTSSource("SrcCol")

    end if

    3) Click Parse

    4) Click OK

    Darren


    Darren

  • I appreciate the code. I was looking for a way to do this for a large number of columns. I have over a hundred columns in the table and wanted to prevent sevral lines of code for each. Is there a another function to perform this?

    -JG


    -JG

  • Trying to do manipulation in the transfer is not always a great idea. I would suggest writing a dynamic script that cycles through the columns in the sql table and updates the columns to null where it is a empty string.

Viewing 4 posts - 1 through 3 (of 3 total)

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