Problem through xp_cmdshell | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Problem through xp_cmdshell

Hi, Iam using xp_cmdshell through query analyzer to copy (Using copy utility)a file from one server to another but iam getting "Access denied error", whereas if i copy through the command prompt directly it works without any error. While executing the xp_cmdshell i am connected as a DBA with sysadmin rights. Also when iam copying the file from one folder to another on the same server it is working fine without any error through query analyzer. Can anyone suggest wht could be the problem. Thanks
Check privileges for SQL Server account on the destination computer. Satya SKJ
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
Below shown is the command iam using exec xp_cmdshell ‘copy D:mssqlMSSQLBACKUPfinancialfinancial_backup_device.bak \dbdbgbomw75015mssql7BACKUPfinancial’ Iam connecting to the host server using windowsNT userid AGRABHU which has a sysdamin rights, also the destination computer also has the same windowsNT userid with sysadmin rights. Bhushan
Yep – as Satya said, the process spawned by xp_cmdshell runs in the security context of the SQL Server Windows Service account (unless specifically otherwise configured), NOT your security context, so you need to check that. For example if it is running under the local SYSTEM account it won’t have rights to do anything on any other network resource – you’d need to use a domain account and grant it rights to other network resources accordingly.
Tom Pullen
DBA, Oxfam GB
Hi, Yaa Thomas i had to change the service account from local system account to a common domain account for both the servers & now the files are getting copied from one server to another using xp_cmdshell. Thanks a lot for the help Bhushan