Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 multiple xcopy in a sql job

Author  Topic 

kiddoOnSQL
Starting Member

16 Posts

Posted - 2011-10-25 : 00:21:06
Hello

I have multiple SQL jobs\agents that pick files from source folders, rename it, and then move it to a common destination folder.
There are 5 source folders and 1 destination folder. Currently I have 5 sql jobs - each of these jobs polls an individual folder although all them (after renaming file in the source), move the file to a common destination.

Now I want to be able to consolidate this to 1 sql job.

While I can achieve this individually, multiple xcopy's dont seem to work in a sql job. I can make this work in a batch file but not in SQL.

The first step in my SQL job is:

Step 1:
XCOPY \\workpc\data\G\Client1\*.XLS \\workpc\data\G\Client1\*.newExt1
XCOPY \\workpc\data\G\Client2\*.XLS \\workpc\data\G\Client2\*.newExt2

It renames files in the first folder (first line of Step1) but does not execute line 2 at all.

Is there a reason why xcopy doesnt work as expected in SQL?

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-25 : 02:27:50
You need to create a .bat-file or to run each line in a separate job step. I think the agent only accepts one-line commands.

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-10-25 : 02:30:41
You should also look in to "robocopy" which is the best file copying utility out there, at least in my opinion. It's standard in Win7/2008 and a part of Win 2003 Feature Pack

-> http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page
   

- Advertisement -