Saturday 12 September 2020

Convert all Blank Space to Null in Flat file SSIS

Some time we get the requirement that to load the csv file into the database and we need to store db null where we are not getting the value or value is blank.

See the example. 

In place of blank we need to store the db null value.

Below is the table

create table TestEmp

(

Id int,

FName varchar(50) null,

LName varchar(50) null,

Mob varchar(10) null,

Addr varchar(100) null

)

 Creating the data flow task to load this file into the database.

Taking the source as flat file and creating the configuration.

                     

See the preview value it shows blank. Now we are loading this file.  

Now loading this file to the database.  

See here for blank space loaded but our requirement is that we need to load db null. For solving this issue, we need to set the below property in the flat file source.

In the advance editor, we need to make check.

Check the highlighted check box.

 Now executing the package

                       

Now see the records in the tables. 

As expected we are getting the null value when the csv file values is blank.

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts