July 16, 2016 at 12:34 pm
I have a stored procedure that needs to move a text file from one folder to another when it is finished importing. I have enabled the xp_cmdshell feature through sp_configure.
Here's my code:
SET @Command = 'Move \\SCMISC\Test.txt \\SCData\Test_20160716.txt';
EXEC master.dbo.xp_cmdshell @Command
It throws Access is Denied error.
The SQL Server instance is "SCMSQL" on a Windows Server 2012 R2 machine. The logon account is "NT Service\MSSQLSERVER".
I've tried granting write permission on the from and to folders to User "NT Service\MSSQLSERVER" but that object name isn't recognized by either server. I also tried "\\SCMSQL\NT Service\MSSQLSERVER".
How do I grant this permission?
July 16, 2016 at 1:28 pm
only a domain account can access server shares, so you'll need to change the service account that SQL is currently running under. NT Service\MSSQLSERVER is not a domain account, so create a mydomain\SQLServiceAccount, grant it access to your specific shares, and your all set.
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply