使用 SQL 身份验证时收到 SSIS 批量插入错误,而使用 Windows 身份验证时可以插入数据。
[Bulk Insert Task] Error: An error occurred with the following error message: "Cannot bulk load because the file "C:\BCP\extract_remove_ref.bcp" could not be opened. Operating system error code 3(failed to retrieve text for this error. Reason: 15105).".
最佳答案
使用 SQL Server 身份验证执行BULK INSERT
时,将按照 documentation 中的指定使用 SQL Server 服务所使用帐户的凭据。 。要解决此问题,请将 BULK INSERT 操作中使用的文件夹/文件的访问权限授予运行 SQL Server 服务的帐户。这可以通过 Windows 来完成,方法是右键单击文件夹/文件,然后转至属性> 安全> 编辑> 添加 并输入帐户名称。如果您找不到它,请确保在对象类型窗口中选择正确的帐户类型,并从位置窗口中选择正确的位置。如果您在查找帐户时遇到问题,请使用检查姓名选项。
更新 1 - 官方文档
引用以下官方文档:
向每服务 SID 授予文件系统权限
- Using Windows Explorer, navigate to the file system location where the database files are stored. Right-click the file system folder, and then click Properties.
- On the Security tab, click Edit, and then Add.
- In the Select Users, Computer, Service Account, or Groups dialog box, click Locations, at the top of the location list, select your computer name, and then click OK.
- In the Enter the object names to select box, type the name of the per-service SID name listed in the Books Online topic Configure Windows Service Accounts and Permissions. (For the Database Engine per service SID name, use NT SERVICE\MSSQLSERVER for a default instance, or NT SERVICE\MSSQL$InstanceName for a named instance.)
- Click Check Names to validate the entry. (If the validation fails, it might advise you that the name was not found. When you click OK, a Multiple Names Found dialog box appears. Now select the per-service SID name, either MSSQLSERVER or NT SERVICE\MSSQL$InstanceName, and then click OK. Click OK again to return to the Permissions dialog box.)
- In the Group or user names box, select the per-service SID name, and then in the Permissions for box, select the Allow check box for Full control.
- Click Apply, and then click OK twice to exit.
其他信息
关于sql-server - 使用 SQL 身份验证时 SSIS 批量插入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55223324/