Hassan Shouman
Hassan Shouman

Reputation: 285

SQL read file, access denied error

I have the following SQL procedure:

   DECLARE @stament as nvarchar(max)

 set @stament='SELECT BulkColumn FROM OPENROWSET (BULK '''+ @Path+''', SINGLE_BLOB) MyFile '

EXECUTE sp_executesql    @stament 

when I execute it, an error occurs:

Cannot bulk load because the file "\MyServer\New Folder" could not be opened. Operating system error code 5(Access is denied.).

I checked the permission on the folder, Everyone has full access, and the file exists.

Thanks

Upvotes: 0

Views: 4472

Answers (1)

Katia
Katia

Reputation: 629

This is usually happens when SQL Server is not allowed to access the bulk load folder. Here is how to fix it: Go to the folder right click ->properties->Security tab->Edit->Add(on the new window) ->Advanced -> Find Now. Under the users list in the search results, find something like SQLServerMSSQLUser$UserName$SQLExpress and click ok, to all the dialogs opened.enter image description here

Also make sure that your user is bulkadmin: enter image description here

Upvotes: 1

Related Questions