0

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

Hassan Shouman
  • 275
  • 4
  • 13

1 Answers1

1

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

Katia
  • 619
  • 6
  • 15
  • I updated answer, try that one with bulkadmin option – Katia Mar 14 '16 at 12:36
  • Thank you for your help, when I test it on non-shared folder it works fine, but the error is for shared folder only.Regarding your suggestion, this works if i am not logging in using 'sa' – Hassan Shouman Mar 14 '16 at 12:58
  • Try the solution from here: http://dba.stackexchange.com/questions/44524/bulk-insert-through-network – Katia Mar 14 '16 at 13:12