Operating system error code 5(Access is denied.)

bhushan 1 Reputation point
2022-06-10T14:31:11.427+00:00

i am getting error when i am triggering stored procedure from application, but i is working fine when executing same procedure from ssms. both the account are same

Cannot bulk load because the file "\f\f1\DEMO\gf3\000000002120220530094502395.txt" could not be opened. Operating system error code 5(Access is denied.)

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,476 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,690 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 116.9K Reputation points MVP
    2022-06-10T21:19:26.077+00:00

    We don't know much here. You say "both the account are same". What exactly do you mean here? Are you logged into SSMS with the same account as the application is running under? And what sort of application is that? A fat Windows client? A web application?

    Here is some information that may help you to troubleshoot the issue further.

    You don't say exactly what code you are running, but the error message suggests that you are running BULK INSERT. When you run BULK INSERT, SQL Server attempts to impersonate you when accessing the file. This means that your permissions will apply. This is not much of a problem if you are logged into to Windows on the machine where SQL Server is running.

    But if you are logged into to computer A, SQL Server runs on server B and the share is on server C, there is a double-hop challenge. When Kerberos and SPNs are configured correctly it works. But if they are not, the access will instead be by the service account of SQL Server. And if this is a local account, the access will be by the machine account, DOMAIN\MACHINE$.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.