bat file will not execute sql agent job

  • 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 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

  • What do you mean by 'bat file will not execute sql agent job'? Is the destination folder created? I don't known exactly what's the current directory when Sql Agent runs, but I guess the 'move *.xls' is causing the problem. You should explicitly specify the source directory where you're Excel files are located, i.e. 'move D:\MyExcelFiles\*.xls ...'.

    Peter

  • my description title was not a good choice i tried to change it but it would not let me.

    No my folder is not created that is what this bat file is to do create a dynamicly named folder based on the current date.

    My file it self is fine it works if i run it in windows manually, but the sql agent does not execute it for some reason.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply