Cannot bulk load. Operating system error code 5 (Access is denied.)

后端 未结 12 1715
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 14:40

For some weird reason I\'m having problems executing a bulk insert.

BULK INSERT customer_stg
FROM \'C:\\Users\\Michael\\workspace\\pydb\\data\\andrew.out.txt\         


        
相关标签:
12条回答
  • 2020-12-02 15:02

    This is quite simple the way I resolved this problem:

    1. open SQL Server
    2. right click on database (you want to be backup)
    3. select properties
    4. select permissions
    5. select your database role (local or cloud)
    6. in the you bottom you will see explicit permissions table
    7. find " backup database " permission and click Grant permission .

    your problem is resolved .

    0 讨论(0)
  • 2020-12-02 15:07
    1. Go to start run=>services.msc=>SQL SERVER(MSSQLSERVER) stop the service
    2. Right click on SQL SERVER(MSSQLSERVER)=> properties=>LogOn Tab=>Local System Account=>OK
    3. Restart the SQL server Management Studio.
    0 讨论(0)
  • 2020-12-02 15:07

    sometimes this can be a bogus error message, tried opening the file with the same account that it is running the process. I had the same issue in my environment and when I did open the file (with the same credentials running the process), it said that it must be associated with a known program, after I did that I was able to open it and run the process without any errors.

    0 讨论(0)
  • 2020-12-02 15:08

    This is what worked for me:

    Log on SSIS with Windows authentication.

    1. Open services and find MSSQL NT Service account name and copy it:

    2. Open folder from which SQL server should read from. Security - Group or user names tab - Add and paste there copied account:**

    1. You will probably get "Multiple names found error", just select MSSQL user:

    Your BULK INSERT query should run fine now. If problem persists try adding SQL Server Agent account to folder permissions in same way. Make sure you restart MSSQL server in services after you are done.

    0 讨论(0)
  • 2020-12-02 15:14

    I don't think reinstalling SQL Server is going to fix this, it's just going to kill some time.

    1. Confirm that your user account has read privileges to the folder in question.
    2. Use a tool like Process Monitor to see what user is actually trying to access the file.
    3. My guess is that it is not Michael-PC\Michael that is trying to access the file, but rather the SQL Server service account. If this is the case, then you have at least three options (but probably others):

      a. Set the SQL Server service to run as you.
      b. Grant the SQL Server service account explicit access to that folder.
      c. Put the files somewhere more logical where SQL Server has access, or can be made to have access (e.g. C:\bulk\).

    I suggest these things assuming that this is a contained, local workstation. There are definitely more serious security concerns around local filesystem access from SQL Server when we're talking about a production machine, of course this can still be largely mitigated by using c. above - and only giving the service account access to the folders you want it to be able to touch.

    0 讨论(0)
  • 2020-12-02 15:14

    1) Open SQL 2) In Task Manager, you can check which account is running the SQL - it is probably not Michael-PC\Michael as Jan wrote.

    The account that runs SQL need access to the shared folder.

    0 讨论(0)
提交回复
热议问题