Linux上的SQL Server>批量导入错误

时间:2022-10-04 21:21:31

did you ever get this error when trying to bulk insert a .tsv file into sql-server-linux docker image:

尝试将.tsv文件批量插入sql-server-linux docker镜像时,是否遇到此错误:

Referenced external data source "(null)" not found.

未找到引用的外部数据源“(null)”。

Here's the command, table exists, file exists on server:

这是命令,表存在,文件存在于服务器上:

BULK INSERT countries FROM '/import/file.tsv'
WITH (
  FIELDTERMINATOR = '\t'
);

Thank you Thomas

谢谢托马斯

1 个解决方案

#1


0  

This is a bug in SQL Server on Linux with how we handle paths. We are still working through getting everything in SQL Server to handle Linux path syntax. I've filed a bug on this and we'll get it fixed. In the meantime, you can specify the path as C:\import\file.tsv where C:\ is a placeholder for the root of the Linux file system (i.e. '/') and the slashes are just reversed. I tested this exact scenario in a RHEL VM and it works fine. Pro tip: This C:\ trick will work anywhere that paths are passed in T-SQL so if you run into this kind of an issue for something else requiring paths, give it a try.

这是Linux上的SQL Server中的错误,我们处理路径的方式。我们仍在努力使SQL Server中的所有内容都能处理Linux路径语法。我已经提交了一个错误,我们会修复它。在此期间,您可以将路径指定为C:\ import \ file.tsv,其中C:\是Linux文件系统根目录的占位符(即“/”),斜杠只是反转。我在RHEL VM中测试了这个确切的场景,它运行正常。专业提示:这个C:\技巧将适用于在T-SQL中传递路径的任何地方,因此如果您遇到其他需要路径的问题,请尝试一下。

Bug #9380471 for Microsoft-internal reference.

Bug#9380471 for Microsoft-internal reference。

#1


0  

This is a bug in SQL Server on Linux with how we handle paths. We are still working through getting everything in SQL Server to handle Linux path syntax. I've filed a bug on this and we'll get it fixed. In the meantime, you can specify the path as C:\import\file.tsv where C:\ is a placeholder for the root of the Linux file system (i.e. '/') and the slashes are just reversed. I tested this exact scenario in a RHEL VM and it works fine. Pro tip: This C:\ trick will work anywhere that paths are passed in T-SQL so if you run into this kind of an issue for something else requiring paths, give it a try.

这是Linux上的SQL Server中的错误,我们处理路径的方式。我们仍在努力使SQL Server中的所有内容都能处理Linux路径语法。我已经提交了一个错误,我们会修复它。在此期间,您可以将路径指定为C:\ import \ file.tsv,其中C:\是Linux文件系统根目录的占位符(即“/”),斜杠只是反转。我在RHEL VM中测试了这个确切的场景,它运行正常。专业提示:这个C:\技巧将适用于在T-SQL中传递路径的任何地方,因此如果您遇到其他需要路径的问题,请尝试一下。

Bug #9380471 for Microsoft-internal reference.

Bug#9380471 for Microsoft-internal reference。