Import selected columns from a CSV files to SQL Server table

て烟熏妆下的殇ゞ 提交于 2019-12-04 05:21:37

问题


I am trying to import data from a CSV file to a SQL Server 2008 table. Data upload is working, but I want to import only selected columns, not all, and add them to a a new table, of same no. of columns, using the wizard, but its not happening, the wizard is selecting all the columns.

So is it possible using wizard that I only import selected columns.


回答1:


If you are using the Import / Export wizard, when you get to Select Source Tables and Views click on the button "Edit Mappings" on the bottom left of the screen. That opens column mappings screen; on the destination column select Ignore to remove the column you don't want to import.




回答2:


Since most people searching this question in 2019 aren't going to be using SQL2008, I'll add this for SQL Server 2016:

When you choose your Flat File data source, there is an Advanced option to the left of the window. Click that.

You will see a list of field names, and just below that there are 3 buttons. One of them is Delete.

Highlight the field you do not want to include and click the Delete button. Do this for all fields you do not wish to import.



来源:https://stackoverflow.com/questions/3446706/import-selected-columns-from-a-csv-files-to-sql-server-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!