Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Execute a CMD file from within a SQL job

Author  Topic 

CanadaDBA

583 Posts

Posted - 2009-06-22 : 14:18:32
I have a Scheduled batch file that copies BAK files from prod into DR box (in another country) every night starting at 8pm. There is a SQL job in DR box which starts at 10:30 pm and restores the BAK file.

Sometimes the BAk files are not available at 10:30 and the SQL job fails. I want to add the execution of the batch file inside the SQL job, to guaranty the restore. I mean, the first job step would copy the BAK files into DR and the second step will restore the BAK files.

The first step is:
EXEC master..xp_CMDShell 'C:\Copy_Backups_from_Prod.cmd'


I added the domain account which was used to run the batch file, to SQL Server and granted SA role. I also changed the owner of SQL job to this account. But whenever the job starts, it fails and gets Access is denied error.

What should I do?

Canada DBA
   

- Advertisement -