1

I am trying to import some data from a .csv file in SSMS using the "Import Flat File" option. However, not all the data is being copied.

Both data types are set to nvarchar(50).

The lines containing just a single value after the semi-colon is imported. Lines with multiple values are imported as NULL. I've tried separating the values with forward slashes and commas. The result is still the same.

How can I get the values imported instead of these NULL values?

enter image description here

nix
  • 4,501
  • 5
  • 22
  • 19
  • This is a sample of data from a larger file. When I try to import this sample, everything works. The larger file results in the problem described above. – nix Aug 12 '19 at 11:41
  • What do you mean by the lines with multiple values after semi colon? Is `;` or `,` your delimiter? If it's `;` then there is only **two** values on line 3,`963420` and `62,63,64,65`; the second string is a **single** value. If it's `,`, then your file is malformed. – Thom A Aug 12 '19 at 11:43
  • The delimiter is ; – nix Aug 12 '19 at 12:28
  • Yes, there are two values on line 3. But when I import, the second value is NULL – nix Aug 12 '19 at 12:29
  • 1
    I'm guessing you set the second column to be a numerical data type? `'62,63,64,65'` isn't an `int`. – Thom A Aug 12 '19 at 12:32
  • I set it to be nvarchar(50) because it contains commas. – nix Aug 12 '19 at 12:36

1 Answers1

1

I tested on my local machine with your example and everything is ok.

Maybe there is an issue in your flat file, have you checked your file is coherent (appropriate < CR >< LF > for example) in Notepad++ ?

Also, during the import, Is the result you see in the "preview" window correct ?

Hugo Salaun
  • 206
  • 1
  • 6
  • I tried to see in the preview window but I didn't have any data with commas in the first 50 lines or so. I moved some up and tried to import again and these were visible correctly in the preview. It is now correct in the table as well. Thank you. I am not sure why this fixed it though. Anyway, the preview window helped! – nix Aug 12 '19 at 15:20