Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am unable to execute batch files to copy backups from SQL Server 2008 R2 hosted on Windows 2008 R2 to a file share.

Error:

Access denied

SQL Server Agent service has full control on the soure and destination folders.

This only happens in Windows Server 2008 R2 on my production environment, suspecting additional security controls on Windows Server 2008 causing this issue.

share|improve this question
    
access denied means the account that is trying to access dont have access to the file share. Check security settings or with your windows Admin. –  Kin Jul 19 '13 at 12:58
2  
What account is the SQL Server Agent service logging in as? Have you logged in as that user and verified that they do have rights to the file share? –  Aaron Bertrand Jul 19 '13 at 14:25
    
Hi Aaron,Thanks for the reply, yes i did verify the permissions it can able to write it with the account. Will there be any security policy in windows2008 will prevent it to be writing? –  Sun27 Jul 19 '13 at 14:41
1  
If you log in as the SQL Server Agent service account (assuming you can) are you able to run the bat file? Are you using xp_cmdshell to execute the bat file or a command step in your job? Do you have a "Run As" set for the job step? –  Kenneth Fisher Jul 19 '13 at 15:59
1  
Kenneth's answer has some good advice. Keep in mind that you also need to look at the NTFS and share permissions. The more restrictive of the two permissions sets will apply. –  James Jul 20 '13 at 10:16
show 1 more comment

1 Answer

If you are running the batch file through xp_cmdshell you are using a different set of permissions. Here is the BOL entry for xp_cmdshell.

Basically though if you are running it as a sysadmin then xp_cmdshell uses the service account for SQL Server, not the service account for the Agent. If you are not running it as a sysadmin then it uses a proxy account. The proxy account is stored in credential called ##xp_cmdshell_proxy_account##.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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