Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql agent not running bat file..

Status
Not open for further replies.

lisat76

Programmer
Joined
Sep 25, 2007
Messages
89
Location
US
Sql 2005
I created a sql job with the sql agent to run to bat files the first step runs a bat file that imports some data into an access db from excel
that works just fine. The second/last step executes another bat file that is to create a folder that is named after the date and move the imported files into an archive folder

here is the contents of my second bat file i checked the history and the log but they did not provide any relevent info
if i run the bat file in windows by it self it works fine.


FOR /F "TOKENS=2-4 DELIMS=/ " %%a IN ("%date%") DO SET dd=%%a&SET mm=%%b&SET yy=%%c

MD D:\DB\pcorfiles\archive\"%yy%-%mm%-%dd%"

move *.xls D:\DB\pcorfiles\archive\"%yy%-%mm%-%dd%"

I tried combining my two bat files also it worked in windows but not in the job.
Help is appreciated thanks
 
I would guess that the it is a permissions error. Jobs run withthe persmission of the SQL Server agent and runnig it in windows would use your permissions.

"NOTHING is more important in a database than integrity." ESquared
 
that would not seem to make any sense considring that my other bat file runs just fine.
 
If the batch file which runs only performs reads and the other performs writes (creating folders), then it could still be a permissions issue.
 
good point, however i just gave the sql servr agent user access to the folder i am moving the files from/to and still the sam issues. I gave it read write permissions.
If there some other user account i ned to give permissions to?? I am using the sql agent service account to run the job in sql

thanks
 
I just check my history log it says the job is running as the local admin for the server. Any other ideas??
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top