3

I am using "Import Flat File" wizard in the SQL Server 2017 to import a .txt file into the database. Below screenshot shows the steps:

enter image description here

Once I select the file location, I see the data preview. In data preview, I don't see the column names. Wizard has ignored the column names which are present in the file and assigned column1, column2, etc as column names.

enter image description here

I have column headers in the file I am trying to import. But wizard is not detecting this -

enter image description here

This issue is happening with only 2 files. I imported 2 other files and wizard was able to detect the column headers in those files.

I tried converting .txt file into .csv file. In this case, wizard treats the column headers as one of the rows and assigns column1, column2, etc as column names.

Please let me know if there is a way to force the "Import Flat File" wizard to treat first row as column headers.

Rashmi Shivanna
  • 85
  • 2
  • 14
  • 1
    Use the "Import Data" option instead (just below your task selection). It has the option to select flat file as a data source which provides a dialog with lots of options such as text qualification, ignoring rows, and the ability to specify if the first row contains columns or not. – RThomas Aug 08 '19 at 03:08

2 Answers2

4

The column headers will be missing if the number of delimiters in the header does not match the number of delimiters in the data

  • This was the answer for me, thank you for posting this. – Gary.Townsend Feb 05 '20 at 20:04
  • 4
    I have a UTF-8 CSV file with exactly matching headers and columns and it still isn't identifying them - so something else must be tripping it up. – Dai Mar 23 '21 at 08:17
1

If one of the headers in the import file exceeds the 128 character limit for column names, the import will not identify any of the column names.