Saturday, June 2, 2012

cannot execute xp_cmdshell. Access is denied while copying data over the network

Today i faced a problem, i was trying to copy some of the files from one server to another server using xp_cmdshell, while executing it was giving error that "Access is denied while copying data over the network".
Here is the T-SQL that i was trying to execute.
Exec xp_cmdshell 'copy D:\SQLBACKUP\Test.bak \\TEST-10\SQLBACKUP'


Steps need to check
1. Check  xp_cmdshell is enabled or not  in server configuration
2. Check if required user has a permission on destination folder.
3. Third and important point is that SQL Server (MSSQLSERVER)  should run under some domain account(service account). It should not run under Local System.

If SQL service is running under Local system, xp_cmdshell will not be able to copy any files to the network location. xp_cmdshell can only copy to the local drive.

































No comments:

Post a Comment