Sql-server – Import Data replaces NULL with 0

importsql serversql-server-2008-r2ssms

I am using sql server 2008 r2 express. I am getting some problems when i use import data feature to import data from one database to another. I am using SSMS to do it. While using the wizard i choose "Select identity insert" option to copy the identity element property. By using this identity elements are imported properly. But after importing i compared the source database and destination database and found some changes!!. All NULL values in the table are replaced by 0. So how can i avoid it.Is there any option to copy it as it while using import data wizard? Please help

Best Answer

Choose to save the package instead of running it right away.
Then edit the dtsx file and on your copy task check "keep nulls".
Then run the dtsx.
I didn't test it but think it will solve your case. enter image description here


Testing the suggestion on the comment on express with advanced services... it worked well:) You create the destination table, set a null default on the column and after importing data with the dtsx you remove the default or set it to whatever you want. dtsx import will replace nulls with the default value of the column when you can't check the "keep nulls".

create table dbo.test (
 a int null
 , other columns ...
 )

alter table dbo.test add constraint x default null for a

--Run Import task here

alter table dbo.test drop constraint x