0

I have an issue with a service account that is used to import several files on its D: drive. In the past SA was used for this process, but of course it needed to be replaced by a service account. So I'm currently trying to find the correct permissions needed.

The user has r/w access to its tables and there is a file share (D:\Statistic) setup where "everyone" has read access.

Problem is the user cannot reach the location currently unless I make him a sysadmin.

To test the access outside of running the actual procedure I use:

EXEC Master.dbo.xp_fileexist 
'\\SRV1\Statistic\Statistic_2024.csv'

Bulkadmin or other roles do not suffice, and I had no luck with the server permissions so far. So in general, I'd guess the share is accessible but I'm missing a specific permission on SQL or system side that is only ignored due to specific exceptions in the sysadmin role.

Any ideas what I'm missing?

4
  • What is the actual file system command that the procedure runs?
    – J.D.
    Commented Feb 1 at 13:51
  • Basically this: BULK INSERT dbo.statistic_import FROM '\\SRV1\Statistic\Statistic_2024.csv'
    – El_Macho84
    Commented Feb 2 at 7:19
  • So you're not using any xp_ procedures. The problem is with the BULK INSERT command?
    – J.D.
    Commented Feb 2 at 13:48
  • No, I just used it for checking file/folder access. The bulk insert is not able to access the file location, same with sys.dm_os_file_exists. So the general problem is the access to the file/directory.
    – El_Macho84
    Commented Feb 6 at 7:55

2 Answers 2

0
  1. Instead of Master.dbo.xp_fileexist try

    SELECT * FROM sys.dm_os_file_exists('\SRV1\Statistic\Statistic_2024.csv');

  2. Sign the stored procedure with sysadmins's certificate https://www.sommarskog.se/grantperm.html

1
  • Thanks for the info, but in case I run into the same issue again I'd like to find a solution outside of granting sysadmin privileges, even to a procedure. But definitely an interesting option to know.
    – El_Macho84
    Commented Feb 2 at 7:22
0

The bulk insert is not able to access the file location, same with sys.dm_os_file_exists. So the general problem is the access to the file/directory.

The access to the directory is going to be based on the folder permissions provisioned to the SQL Server service account that your instance runs under. At the end of the day, that's what those types of operations get executed as.

If you're getting file locations access issues, then this has nothing to do with SQL Server permissions internally, or SysAdmin, or anything of that nature. You should provide the exact error message you're getting either way.

2
  • Ok, granting the Service account NT Service\MSSQLSERVER explicit permissions to the share has solved the issue. It seems like it is not included in "everyone" as I initially guessed. Issue Solved. thanks!
    – El_Macho84
    Commented Feb 7 at 9:10
  • @El_Macho84 I think that's because it's a different kind of service account, but I'm not an expert on network administration. Glad it's working! If you found this answer helpful, feel free to upvote or accept it so others with the same problem also find it useful.
    – J.D.
    Commented Feb 7 at 13:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.