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

后端 未结 12 1753
没有蜡笔的小新
没有蜡笔的小新 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: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.

提交回复
热议问题