Solved

Copying file from one server to another

Posted on 2014-02-22
7
229 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 51

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 51

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 51

Expert Comment

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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

743 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

14 Experts available now in Live!

Get 1:1 Help Now