DTS & CSV Import Files

  • Hi,

    I am exporting/importing with DTS using CSV files and quotedidentifiers. However, the NULL varchar columns do not get recognised as NULLs. They are set as ,"", on export. Therefore when the data is imported it is imported as an Empty String. Is there an easy way that this can be avoided without having to write a VB function to set it to NULL? I have 40-50 tables I need to export/import.

    Thanks

    steve.

  • I'm new to DTS too but doesn't the Keep NULL Values check box do this??


    Mike at the Mill

  • Afraid not. That dictates whether a default value is applied or not. ie. Keep Nulls even though a default constraint exists.

  • Durn!  Looks like you'll have to write script code on the transformation.  Sorry!


    Mike at the Mill

  • CSV is a type of "text" file, NULL is a "binary" value.

    If you need to keep the NULLs, export/import with a binary data destination, like an Access Database.

     


    Julian Kuiters
    juliankuiters.id.au

  • Assuming NULL is permitted in the column/table and there are no default values for the column, then omitting the field from the import file should automatically assign a null value on import.

    Try it with a test file and table first..

  • On import if you have empty strings and you want them represented as NULL in the database you'll have to code a transformation formula that tests the source field for "" and, if true, sets the destination field to NULL.

    On export to CSV are you looking to get "field1",,"field3" instead of "field1","","field3"? If so you may have to do some more serious coding. You can try setting the output field to NULL instead of "" if the input field is NULL, but I'm not sure CSV will handle that. It may just translate it back to "". You'll have to experiment. You will have to do some type of coding in the transform data task to handle your special requirements.

     

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

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