SQL xp_cmdshell copy files not working using network path

I am running into a problem when trying to copy a file using xp_cmdshell in SQL 2005 using a network path (works fine using a local path).  Assuming some sort of permissions issue but not sure why/how.

I have the script:
EXEC master.dbo.xp_cmdshell 'copy c:\test.txt c:\temp\'

This works fine but when I try to use the network paths (to the same exact folders just using the network paths it does not work with "Access denied" message.

EXEC master.dbo.xp_cmdshell 'copy \\ServerName\C$\test.txt \\ServerName\C$\temp\'

The folders are the exact same:
C:\ = \\ServerName\C$\
c:\temp = \\ServerName\C$\temp\

just not sure why it works using local paths but NOT server paths.

LVL 16
Who is Participating?
That's because the SQL account executing that procedure need access to that OS network path.
brad2575Author Commented:
It should already have it.  The account on the server is running SQL under a network ID that should have the permissions already.

The network path is the same as the local path (just going through the network).  What is the difference and how would I tell if it does not have it and how could I get it added then.
Another possibility is running this in SQL

exec xp_cmdshell 'whoami'
And then make sure that the service account has access to the folder in question.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.