Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Stored Procedure to Copy files from one server to another server

Posted on 2004-09-17
7
Medium Priority
?
609 Views
Last Modified: 2011-04-14
I have files in intranet site that I want to copy to internet site.
Here is my stored procedure. when I execute it, it says the path not found. I know that it couldn't fine the path of the internet site, it is \\ccinter\InetPub\wwwroot\BOS\MeetingMinutes\This is a test file.htm. But I don't know how to change the code. Please help. thanks

CREATE PROCEDURE [sp_Minute] AS
DECLARE @IntranetFile varchar(255),@InternetFile varchar(255),@cmd varchar(255)

SET @IntranetFile = '"C:\InetPub\wwwroot\This is a test file.htm"'
SET @InternetFile = '"\\internet\InetPub\wwwroot\This is a test file.htm"'

select @cmd = 'move ' + @IntranetFile + ' ' +  @InternetFile


        exec master..xp_cmdshell  @cmd
0
Comment
Question by:CochiseCounty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
apirnia earned 336 total points
ID: 12087097
0
 
LVL 9

Expert Comment

by:apirnia
ID: 12087128
Just a note:

the stored proc can only see local drives to the SQL Server, for drives on other PC it would be an UNC path (\\workstation\C$\), for which the (admin) permissions need to be given
0
 
LVL 43

Assisted Solution

by:Eugene Z
Eugene Z earned 332 total points
ID: 12087262
make sure the NT account that you r using has NTFS permissions on souce and destination folders


When you go in start->run on sql server and type \\internet\InetPub\wwwroot\
can you open the folder?
0
 
LVL 5

Assisted Solution

by:ajitanand
ajitanand earned 332 total points
ID: 12111347
I believe the stored proc is getting in trouble because of spaces in the file name.

The stored procedure will work if you specify the filename in an old fashioned format as:

SET @IntranetFile = '"C:\InetPub\wwwroot\Thisis~1.htm"'
SET @InternetFile = '"\\internet\InetPub\wwwroot\Thisis~1.htm"'

-------------------------------
Just give a try and let me know if that helps.

Another reason could be NTFS permissions/sharename. To fix that you can do this:

Step 1. Map the share name (\\internet\InetPub\wwwroot\) as a Network Drive (say H:), and specify alternate the username/password of a user who has rights to access the folder while mapping the drive.

Step 2. Move the file using the location as:
SET @InternetFile = '"H:\This is a file.htm"'
or
SET @InternetFile = '"H:\Thisis~1.htm"'

-------------------------------------------
rgds,
Ajit Anand

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question