Djbril
Djbril

Reputation: 895

Import blank cells as NULL in CSV

I want import an SQL Table and I want the empty cells as NULLs using SSIS. So I want the csv file to contain Nulls instead of blank cells.

Thanks

Upvotes: 1

Views: 7781

Answers (3)

TechnoKid
TechnoKid

Reputation: 23

  1. Whilst in the SQL Server Import and Export Wizard, select the 'Edit Mappings' button

enter image description here

  1. Once you can see your column mappings, click on the destination for the column you want to remain as NULL and select ignore

enter image description here

Upvotes: 0

Umberto
Umberto

Reputation: 2060

To convert source blanks into table NULLs:

  1. In the Flat File Source Editor enable Retain null values from the source as null values in the data source
  2. In the OLE DB Destination Editor enable Keep nulls

Upvotes: 4

Zane
Zane

Reputation: 4169

In your data set all you need to do is add a derived column and set the value to this.

YourColumn == "" ? NULL(DT_WSTR,50) : YourColumn

You may also be able to check the box on the source that says keep null values to solve the issue. RetainNulls

Upvotes: 3

Related Questions