Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reading data from replication SQL database 7 87
SQL Select - Finding chars in a column 2 56
SQL Agent Timeout 5 47
Upgrading SQL 2005 Express to 2008 R2 Express 31 67
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

23 Experts available now in Live!

Get 1:1 Help Now