I am trying to execute a batch file from SQL Server 2012 JObs with the following command
cmd.exe /c "D:\Batch Files\SQLDBBkupCopy.bat".
The objective of the batch file is to copy SQL DB backup to a different machine in the network. The Job successfully ran, but there was no files copied.
From the Jobs history I could able to see this error message:
Executed as user: SLC\sqlagentservice. Invalid drive specification 0
File(s) copied. Process Exit Code 0. The step succeeded.
Here is my Batch file script:
***********Start******
@echo off
cls
echo.------------------------>>CopyLog.txt
echo.%Date% %Time%:- INITIATING FOLDERS......>>CopyLog.txt
set folder1="B:\SLCBackup\ForSymantec"
set folder2="\\testsvr\c$\SQLBKUP\SLCDBAREN"
echo.%Date% %Time%:- Initiation Complete.....>>CopyLog.txt
echo.%Date% %Time%:- Copying from %folder1% to %folder2% >>CopyLog.txt
xcopy /E /C /R /I /K /Y %folder1% %folder2%
echo.%Date% %Time%:- Complete...>>CopyLog.txt
*****End*********
However, if I try to copy in the same machine like:
set folder2="c:\test1"
it then works.
Best Answer
For any interaction with the Operation System, insure that the user services of SQL Server has the privileges