Can someone help me with these?

FROM '\\COMPUTER01\FOLDER01\TextFile.txt'
    rowterminator = '\n',

The error shows, couldn't open:

Could not bulk insert because file '\SERVERNAME\FOLDERNAME\textFile.txt' could not be opened. Operating system error code 5(Access is denied.)

The path is on another computer on the network.

  • 8
    Does the account that SQL Server is running under have permission to access '\\COMPUTER01\FOLDER01\TextFile.txt'? Note that the account will generally be different from your account. – Damien_The_Unbeliever Jun 13 '13 at 8:55
  • 3
    Can you also add the exact error you get? – ypercubeᵀᴹ Jun 14 '13 at 11:22
  • in addition to @Damien_The_Unbeliever: "To specify a shared data file, use its universal naming convention (UNC) name, which takes the general form, \\Servername\Sharename\Path\Filename" – JoseTeixeira Jun 14 '13 at 11:52
  • @ypercube - Could not bulk insert because file '\\SERVERNAME\FOLDERNAME\textFile.txt' could not be opened. Operating system error code 5(Access is denied.). thank you sir – Jonas Ivy V. Imperial Jun 15 '13 at 2:43
  • I have the same issue using the same domain and cross domain (Operating system error code 5(Access is denied.)). Interestingly, if I use XP_CMDSHELL to test if the file exists or i can even move the file, but the bulk insert throws access denied. The sql service account and my windows account both have permissions to the folder. – user53311 Dec 3 '14 at 2:00

I'm going to make a leap of faith and assume you connect to SQL Server using Windows Authentication. In such a case you have a Kerberos double hop: one hop is your client application connecting to the SQL Server, a second hop is the SQL Server connecting to the remote \\COMPUTER01. Such a double hop falls under the restrictions of Constrained Delegation and you end up accessing the share as Anonymous Login and hence the Access Denied.

To fix the problem you need to enable constrained delegation for the SQL Server service account. This blog How To: SQL Server Bulk Insert with Constrained Delegation (Access is Denied) has an example of how to do it, and I really do hope that the step on how to 'enable unconstrained delegation' is just a typo as unconstrained delegation is just plain evil.

In the case I jumped the gun and you are logging into SQL Server using SQL Authentication you will need to create a credential for your SQL login and use that to access network resources. See CREATE CREDENTIAL.


I would run the script under a SQL Login (with bulkadmin permission) and let the permission on the network folder authenticate against the SQL Service Account or SQL Server Agent account.


Sql Server tried to open file, file server told it "Access denied" because the account SQL Server runs under has no permission to open the file. Change security settings on the file accordingly and it will work.


I'll tell you what works for me every time i get this message. i open the csv file as a text in a notepad and delete all the space lines in the file,i cant see those blank lines in the excel file. Usually its just the last line that seems to appear even though its empty

  • Are you sure it's the same error? – dezso Dec 2 '15 at 9:58
  • This has nothing to do with Access Denied errors. This only fix file format errors. – Julien Vavasseur Dec 2 '15 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.