During transformation, how to handle NULL values in Destination table

  • Hello folks,

    I have a DTS package that exports records from an old table strucutre to a new table structure. After executing my DTS package, the new fields in my destination table are getting NULL values. I would rather NOT insert Null values.

     Is it just a matter of setting up default value constraints or is there a way I can force real values in those fields in my DTS package.

    I also figure I can write a stored procedure that will get fired from my DTS after the data has been inserted.

    Thank you in advance,

    Bob

  • There are many ways to tackle this beast.  Default values are an option, using a sql stored proc (as part of the DTS or afterwards) is an option, using a script is also an option.

    Tell us more about what you want to happen so we cah help you figure out how to make it happen.

  • Thanks for your response, Pam. It turns out that I just added an "Sql Task" to my DTS to handle those Null columns; the Sql code inside that sql task is simply:

     Update orders set <column> = ' ' where <column> is null

    It's rather innefficient because I repeat that line about 15 times for the 15 columns that require default values; however, it's very straightfoward and does the job. It's really a small table with only a few hundred records so speed is NOT an issue in this case.

    Have a great day !

    Bob

  • That a good enough solution for a table that will be populated by your DTS only, but what happens when you use that table in an application that can write/update it? You will then have to program the NULL out inside your application as well.

    Turning off nulls for that column will default it to the default value for the datatype.

    (i.e. char will default to '' (empty), int will default to 0 (zero), etc....)

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

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