Solved

error in moving a file using Operating System[CmdExec], sql agent service account

Posted on 2009-04-14
5
1,711 Views
Last Modified: 2012-06-21
I am trying to move a .bak file from one folder to another folder using Operating System(CmdExec), sql agent service account in configuring job step properties. In the command line, i have written move command like
ex: move "E:\foldername\*.bak" "F:\foldername"
but the job fails with the error "The process could not be created for step 1 of job 0xEA5D4EF4E6D063791FB533167 (reason: The system cannot find the file specified).
The same move command work's fine in dos command prompt.
What should i check to make sure that the system can find the file location path? or any settings to be changed to share these folders?
 
Thanks,
hari.
0
Comment
Question by:krishna_harik
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:reb73
ID: 24136633
Are the drives E: and F: local non-removable drives in the server (or in other words network shares mapped as E: or F:)?

Run the following command in SQL Query window to see if the E: and F: drives appear in the list of results -

exec master..xp_fixeddrives

If they don't appear, then you have to use the full UNC path reference (\\server\share\filename.bak) in your job command.. You may also need to ensure that the SQL Agent Service account has full rights on these shares..

0
 

Author Comment

by:krishna_harik
ID: 24136860
These drives E: and F: are of local non-removable drives. i have run the command
exec master..xp_fixeddrives -- > i could see all the list of drives with available space in it.

how to check whether SQL Agent Service account has full rights on these shares?
Before doing this in production server, i want to test it in my desktop system.
0
 
LVL 25

Expert Comment

by:reb73
ID: 24137012
Actually try using the command 'move "E:\foldername\*.bak" "F:\foldername"' within a command batch file (test.bat) and call this batch file from the job step to see if it works..

0
 

Author Comment

by:krishna_harik
ID: 24137694
reb,

Thank you very much for your assistance, this worked perfectly!
please, write the commands which i need to add in creating a batch file to move the files,  like
ex:
:START
move "E:\foldername\*.bak" "F:\foldername"
IF errorlevel 1 GOTO MKFILE
GOTO :END

:MKFILE
ECHO file text>file.txt
GOTO START

:END
ECHO Quitting
PAUSE

because, this is the first time i created a batch file.
0
 
LVL 25

Accepted Solution

by:
reb73 earned 500 total points
ID: 24139019
Just a simple Move command on its own within the .bat file should suffice for what you need..

MOVE "E:\foldername\*.bak" "F:\foldername"

If there is a chance that the target file already exists, the command above will fail as it will wait for confirmation in interactive mode. If it is ok to overwrite without confirmation use the following command -

MOVE /Y "E:\foldername\*.bak" "F:\foldername"

If you need the batch file invocation to succeed regardless of whether the source file exists or not, use the IF EXIST check as follows -

IF EXIST "E:\foldername\*.bak" MOVE /Y "E:\foldername\*.bak" "F:\foldername"

The command above will move if the source file exists, and do nothing otherwise..

Optionally you can also use @ECHO OFF as the first line to prevent commands from being echoed/displayed in command window but this is not essential..
0

Featured Post

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.

Join & Write a Comment

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 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

18 Experts available now in Live!

Get 1:1 Help Now