I import data from a TSV file with SQL Server 2008.

null is replaced by 0 when I confirm a table after import with integer column.

How to import as null, please Help me!!

link|improve this question

39% accept rate
you mean csv??? – Nick Kavadias Jul 7 '09 at 5:57
TSV = Tab Separated Values. – mrdenny Jul 7 '09 at 6:09
What technique are you using to import the file? BCP, Bulk Insert, SSIS? – mrdenny Jul 7 '09 at 6:10
derrrr.. i knew that ! – Nick Kavadias Jul 7 '09 at 7:12
feedback

1 Answer

up vote 1 down vote accepted

IF you are using a BULK INSERT, did you specify the KEEPNULLS parameter?

BULK INSERT MyTestDefaultCol2
FROM 'C:\importin.txt'
WITH (
  DATAFILETYPE = 'char',
  FIELDTERMINATOR = '\t',
  KEEPNULLS
);

MSDN SQL SERVER DEV CENTER

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.