HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

SSMS - Can not bulk load because the file could not be opened

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
canthessmsfilebulkcouldbecauseopenedloadnot

Problem

We have a user who get this error message every time bulk load using network location it throws error below.

"Cannot bulk load because the file could not be opened. Operating system error code 3(failed to retrieve text for this error. Reason: 15105)."

  • If users logs on the remote server and runs same query it works fine



-
FQDN is specified for the location of the file ( \servername\sharename\filename.txt)

-
When file is copied on the server ( C:\ drive) , query runs fine via SSMS

  • We are using SQL server 2008 R2



I have checked all NTFS permissions for the shared folder.
I have gone through numerous posts suggesting solution but no luck.

Solution

winerror.h lists Operating System Error Code 3 as ERROR_PATH_NOT_FOUND. This likely indicates that \\servername\sharename\filename.txt either doesn't exist or the SQL Server Service Account does not have access to the file via the UNC.

Use SQL Server Configuration Manager to determine the name of the SQL Server Service Account:

Check the Fileshare Security for the UNC to ensure that account has access to the share. Check the Filesystem Security for the folder underlying the UNC to ensure the account has access to the file.

T-SQL BULK INSERT requires an understanding of the security architecture. Taken from that page:

If a user uses a SQL Server login, the security profile of the SQL Server process account is used. A login using SQL Server authentication cannot be authenticated outside of the Database Engine. Therefore, when a BULK INSERT command is initiated by a login using SQL Server authentication, the connection to the data is made using the security context of the SQL Server process account (the account used by the SQL Server Database Engine service). To successfully read the source data you must grant the account used by the SQL Server Database Engine, access to the source data.In contrast, if a SQL Server user logs on by using Windows Authentication, the user can read only those files that can be accessed by the user account, regardless of the security profile of the SQL Server process.

When executing the BULK INSERT statement by using sqlcmd or osql, from one computer, inserting data into SQL Server on a second computer, and specifying a data_file on third computer by using a UNC path, you may receive a 4861 error.

To resolve this error, use SQL Server Authentication and specify a SQL Server login that uses the security profile of the SQL Server process account, or configure Windows to enable security account delegation. For information about how to enable a user account to be trusted for delegation, see Windows Help.

Context

StackExchange Database Administrators Q#185943, answer score: 3

Revisions (0)

No revisions yet.