无法批量加载错误消息

时间:2018-04-09 17:50:13

标签: syntax-error ssms bulkinsert

尝试进行批量插入。样本数据和格式文件如下。我注意到我们需要使用通用命名约定(UNC),因此为什么代码中的'\ FR-6RSGJH2.xyz.st \ C $项。但是,如果你只是'\ C \ Users \ myname \ Desktop \ testimport.csv',就会出现同样的错误。关于语法或任何设置中缺少什么的任何想法可以改变吗?

  BULK INSERT testimport
  FROM '\\FR-6RSGJH2.xyz.st\C$\Users\myname\Desktop\testimport.csv'
  WITH (FORMATFILE = '\\FR- 
  6RSGJH2.xyz.st\C$\Users\myname\Desktop\format.txt')
  GO


  Msg 4861, Level 16, State 1, Line 1
  Cannot bulk load because the file 
  "\C\Users\myname\Desktop\testimport.csv" could not be opened. Operating 
  system error code 3(The system cannot find the path specified.).

示例数据

  32003012017010316
  32001022017040218
  32003032017030213
  32002042017020111
  32002052017020110

格式文件

 13.0
 5
 1     SQLCHAR     0     02     ""         1     st     ""
 2     SQLCHAR     0     03     ""         2     cnty   ""
 3     SQLCHAR     0     02     ""         3     v1     ""
 4     SQLCHAR     0     08     ""         4     date   ""
 5     SQLCHAR     0     02     "\r\n"     5     v2     ""

1 个答案:

答案 0 :(得分:0)

不确定它是如何工作的,但是当我将testimport改为.txt而不是.csv时,它确实有效。无论如何,这就是答案。