[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

UNC Copy -> Local Drive

Dear Experts,

Within SQL Server -- I need to copy from a UNC Share to a Local Drive Path.
Normally I would use xp_cmdshell 'XCOPY \\uncserver\sharename\*.* C:\PATH\'
unfortunatly XCOPY does not support reading from a UNC Share and reports an error of file not found, it does exist.

I can even emulate this by making the UNC share on the local-server itself, anybody know the work around for this ?

I'm open to suggestions...

Thanks All in Advance,

1 Solution
try this TSQL then

Declare @sql varchar(8000)
SET @sql = 'copy \\uncserver\sharename\*.* C:\PATH\*.*'

EXEC master..xp_cmdshell @sql
danblakeAuthor Commented:
That works, so does the XCOPY - -must be getting tired....
Thanks all.

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

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