2

I'm using the export data wizard in sql server 2005.

I've got a table with null values in many of the fields. I'd like to keep these fields as I export to .csv but they are being replaced with empty strings.

I've tried changing the 'nullable' checkbox for the fields in the wizard, but that doesn't seem to do anything. Also tried using " as a delimiter, since without delimiters, NULL would be interpreted as a string.

Sam
  • 7,543
  • 7
  • 48
  • 62
  • Some CSV files contain `\N` for a NULL value, [MySQL does support that](http://stackoverflow.com/questions/2675323/mysql-load-data-null-values). – hakre May 07 '12 at 10:39

1 Answers1

6

There's no such thing as a null in .csv files. Like you said, a value of null, "null" or "" would all be interpreted as a string value. Consider changing your source so it adds a "ColumnXIsNull" value to the exported records.

Ken Browning
  • 28,693
  • 6
  • 56
  • 68
  • What if the csv was delimited like this: "string","string",NULL - wouldn't that work? – Sam Mar 19 '09 at 23:45
  • 1
    If that's ok for you then go for it. Like I said, there's no such thing as a null in csv. However you want to signify that a value should be null is fine... as long as whatever is reading the csv understands your convention. – Ken Browning Mar 20 '09 at 00:47