Import Flat File via SSMS to SQL Server fails

Make sure when you are creating your flat-file IF you have text (varchar) value in any of your columns, DO NOT select your file to be comma "," delimited. Instead, select vertical line "|" or something that you are SURE it can't be in those values. the comma is supper common to have in nvarchar filed.

I have this issue and none of the recommendations from other answers helped me! I hope this saves someone some times and it took me hours to figure it out!!!


If the file you're importing is already open, SSMS will throw this error. Close the file and try again.


Check the following:

  • that there are no blank lines at the end of the file (leaving the last line's line terminator intact) - this seems to be the most common issue
  • there are no unexpected blank columns
  • there are no badly escaped quotes

It looks like the import process loads lines in chunks. This means that the lines following the last successfully loaded chunk may appear to have no errors. You need to look at subsequent lines, that are part of the failing chunk, to find the offending line(s).

This cost me hours of hair pulling while dealing with large files. Hopefully this saves someone some time.

Tags:

Import

Ssms