Solved

Stored Procedure to Copy files from one server to another server

Posted on 2004-09-17
7
546 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
Comment Utility
0
 
LVL 9

Expert Comment

by:apirnia
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now