批量插入特定列? [英] BULK INSERT into specific columns?

查看:49
本文介绍了批量插入特定列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将csv文件的列批量插入到目标表的特定列。
说明-目标表中的列比我的csv文件中的列多。因此,我希望使用大容量插入将csv文件列转到正确的目标列。

I want to bulk insert columns of a csv file to specific columns of a destination table. Description - destination table has more columns than my csv file. So, I want the csv file columns to go to the right target columns using BULK INSERT.

这可能吗?如果是,那么我该怎么做?

Is this possible ? If yes, then how do I do it ?

我在- http://blog.sqlauthority。 com / 2008/02/06 / sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server /

http://www.codeproject.com/Articles/439843/Handling-BULK-Data-insert-from-CSV-to-SQL-Server

BULK INSERT dbo.TableForBulkData
FROM 'C:\BulkDataFile.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

它们不显示

推荐答案

是的,您可以执行此操作。最简单的方法是只创建一个从目标表中 Select s的视图,并按照数据在列表中出现的顺序列出希望数据访问的列。源文件。然后批量插入到视图中,而不是直接到表中。

Yes, you can do this. The easiest way is to just create a View that Selects from the target table, listing the columns that you want the data to go to, in the order that they appear in the source file. Then BULK INSERT to your View instead of directly to the Table.

这篇关于批量插入特定列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆