Solved

Copying file from one server to another

Posted on 2014-02-22
7
236 Views
Last Modified: 2014-03-10
Hi,

 I have the names of file path in a MS SQL 2005 table in the following format:

Path Filename
Myfileserver\ABC  abc.txt
Myfileserver\DBC  dbc1.txt

etc

These can be dumped into a flat file called processfiles.txt residing on the SQL server, which would contain the following contents:
Myfileserver\ABC\abc.txt
Myfileserver\DBC\dbc1.txt

I wanted to write a batch script that will reside on a different server than the SQL server and will need to copy those files in the table and put them on a folder on the current server.

How do I accomplish this?
0
Comment
Question by:LuckyLucks
  • 3
  • 2
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Don Thomson
ID: 39879668
something like this may work

for %%f in (Myfileserver\abc\*.txt) DO type %%f>>\\Otherfileserver\whateverfolder\processfiles.txt
do this for each folder
0
 
LVL 55

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39879710
Is there any reason you can't dump the content from the SQL server directly to a BAT file. In other words

copy Myfileserver\ABC\abc.txt \\otherserver\path\abc.txt
copy ...

Open in new window

0
 

Author Comment

by:LuckyLucks
ID: 39879809
The problem is Myfileserver\ABC and Myfileserver\DBC etc are dynamically produced in the table. So prior to this question, there is a button thats presses, stuff happens and the table containing the two folder locations is created. It could  be a different number and name of folders the next time around. Each folder also may have a different number of files in it each time. Hence, any hardcoding is not going to work.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 55

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 39880635
No, what I mean is, as I understand your setup some process is producing a file
These can be dumped into a flat file called processfiles.txt residing on the SQL server, which would contain the following contents:

If this process is producing a list of files that another process (bat file) must read then why not simply create the output of the first file as bat commands.

If the destination is dynamic then use parameters i.e.
Output to movefiles.bat
copy Myfileserver\ABC\abc.txt %1
...

Open in new window

And call from second bat file

\\sqlserver\pathtobatfile\movefiles.bat \\someotherserver\somefolder

Open in new window

0
 
LVL 14

Expert Comment

by:Don Thomson
ID: 39881032
Do the original files have to be deleted?
0
 

Author Comment

by:LuckyLucks
ID: 39887378
no originals have to be deleted
0
 
LVL 55

Expert Comment

by:Julian Hansen
ID: 39888031
@LuckyLucas - any response to my previous post?
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

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