Reputation: 111
When I am logged in as the sa user I am able to run the following command:
SELECT *
FROM OPENROWSET(BULK '\\server1\files\test.pdf', SINGLE_BLOB) x
However, when I log in as my windows user who has sysadmin, bulkadmin and serveradmin roles I get the following error:
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\server1\files\test.pdf" could not be opened. Operating system error code 5(Access is denied.).
What permissions am I missing from my Windows user?
Upvotes: 0
Views: 1249
Reputation: 111
I was able to circumvent this problem by creating a SQL job that called my stored procedure where the bulk insert script occurs. When the job is run, the SQL agent credentials are used and the blob is read.
Upvotes: 0
Reputation: 89371
sa
will run OPENROWSET(BULK
as the SQL Server Service Account, which will map to the Machine Account for built-in users like NT SERVICE\MSSQLSERVER
or Network Service
. Windows Logins will run OPENROWSET(BULK
as themselves.
Upvotes: 0