Solved

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

Posted on 2009-04-14
5
1,821 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 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