Forum Discussion
Import from Excel changes Header Names
I have a wide table in Excel with column names like Q1.1, Q1.2, etc. However, when I import this table using SSMS, the column names are renamed to Q1#1#, Q1#2#, and so on.
This renaming is visible when you look at Column Mapping before actually importing.
Is there a way to prevent this renaming? If not, can I write some code to rename the columns afterward? I have 96 columns in this dataset, which I need to upload monthly.
This issue is becoming a nuisance because I want SQL to clean up this dataset before pivoting it and appending it to my final table. Currently, I manually clean up the data in Excel, pivot it, and then upload a tall file with only 4 columns. This method avoids the renaming issue because all the question numbers become values in a column rather than column names.
Could you save your Excel file as .csv file?
I tried use Import wizrd, and choose Flat file source as data source, the column names are correct.
- rodgerkongIron Contributor
Could you save your Excel file as .csv file?
I tried use Import wizrd, and choose Flat file source as data source, the column names are correct.
- olafhelperBronze Contributor
This renaming is visible when you look at Column Mapping before actually importing
And that's the point, where you can also rename then columns for import.
For renaming see Rename columns (Database Engine) - SQL Server | Microsoft Learn