Solved

Stored Procedure to Copy files from one server to another server

Posted on 2004-09-17
7
578 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
  • 2
7 Comments
 
LVL 9

Accepted Solution

by:
apirnia earned 84 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 42

Assisted Solution

by:EugeneZ
EugeneZ earned 83 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 83 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

828 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