1

I am getting Access Denied error ..

Openrowset is throwing error for file access as Access Denied

I tried running these 2 queries as well..

 EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO

SELECT  *   FROM OPENROWSET(BULK '\\MySharedFolder\\TEST\\MyFile.txt',SINGLE_CLOB) AS  ExternalFile;

I am getting an error as

Cannot bulk load because the file "..." could not be opened. Operating System error code 5(Access is denied.).
8
  • I think that your sql server service account does not have enough privileges on that share. Could you check the service account, and the permissions on the share? The DMV you could use is sys.dm_server_services Commented Dec 26, 2018 at 18:24
  • I agree with you.. it was working before... after db restore, this issue started happening. But How do i fix this ? What exactly i have to do with sys.dm_server_services syntax, i will do the same
    – goofyui
    Commented Dec 26, 2018 at 18:28
  • Alright so, you could check (select * from sys.dm_server_services) on the sql server, and see what the sql engine account is. Afterwards, you can go to the share, (\\MySharedFolder\\TEST\) right click properties and go to the security tab. If the sql engine account is not added, add it, and give it full control (which might be overkill, I should look into that). And then try again. If it is not added, check the permissions. Commented Dec 26, 2018 at 18:35
  • 1
    let me check and update you.. thanks again
    – goofyui
    Commented Dec 26, 2018 at 18:37
  • Folder has "Everyone" and "System" access. Still, i am facing the error.
    – goofyui
    Commented Dec 26, 2018 at 18:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.