• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2603
  • Last Modified:

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.



0
brad2575
Asked:
brad2575
  • 3
1 Solution
 
ralmadaCommented:
That's because the SQL account executing that procedure need access to that OS network path.
0
 
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.
0
 
ralmadaCommented:
0
 
ralmadaCommented:
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.
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now