In my recent project, I need to create a Sql server agent job to run a batch file that runs a Sql server integration service package.
Suppose my package name is Test_Package.dtsx and it is situated at the file path D:\Projects\Packages\MyPackage.
To create a windows scheduler for running the package, I need to write a batch file in which the command will be :
“C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtexec.exe” /FILE “D:\Projects\Packages\MyPackage\Test_Package.dtsx” /MAXCONCURRENT ” -1 ” /CHECKPOINTING OFF >>TestLog.txt
Now my target is to run this batch file using a sql job. To do so,
- Open sql server.
- on object explorer tab, select sql server agent and expand the jobs.
- select new job.
- In general tab, named the job and select the category as uncategorized(local).
- Select steps tab and select new steps. Then name the step name, select type as Operating system(CmdExe). In the command open the batch file or write the command cmd.exe /c “D:\Projects\mybatch.cmd”. Here mybatch.cmd is the batch file and D:\Projects\mybatch.cmd is it’s path.
- Then select OK and job is ready.
But in my project, I faced a problem. I created the job as Sql server Agent Service Account. The user of this service account has not the credential to access the database that is used in my package. So, the job failed and said login failure to access database. On the other hand, the user who has credential to access database has no credential to run the CmdExe. To solve the problem I need to create a proxy and a credential.
To create a credential…….
- Expand Security and select credential and select new credential. then create the credential.
Then create the proxy……….
- Expand Sql server Agent and then expand Proxies.
- Name the proxy
- Select Credential
- Select the Subsystem.
Then select this Proxy as Run As when creating the job.
This has worked fine. 🙂