[英]Import CSV file in SQL server
I want to import csv data in sql server. 我想在sql server中导入csv数据。 I searched about and found answers about BULK INSERT ... FROM. 我搜索并找到有关BULK INSERT ... FROM的答案。
The problem I have is : 我的问题是:
The CSV I had contains towns and its parameters (correct datas) 我拥有的CSV包含城镇及其参数(正确的数据)
Town,Id,ZipCode,...
T1,1,12000
T2,2,12100
T3,3,12200
And the table in SQL Server 'town' contains for example T1,1,30456 T2,2,36327 T3,3,85621 SQL Server“镇”中的表包含例如T1,1,30456 T2,2,36327 T3,3,85621
I just want to get ZipCode in CSV and update the ZipCode in the table in function the ID. 我只想获取CSV中的ZipCode并更新ID功能表中的ZipCode。 Does it exist an easy way to do it ? 是否存在简便的方法?
I normally prefer bcp over bulk insert because with that you can easily import the files over network and there's less issues with access rights. 我通常更喜欢bcp而不是大容量插入,因为这样一来,您可以轻松地通过网络导入文件,并且访问权限的问题更少。 Otherwise I would just load the data into tempdb and update the original table from there. 否则,我只是将数据加载到tempdb中,然后从那里更新原始表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.