Friday, March 30, 2012

Scheduling sqlcmd script in sql agent

Is it possible to schedule a sqlcmd script within sqlagent? That is without running a cmdexec?

Thanks,

what is the actual requirement ... its not clear. you can use XP_cmdshell to execute sqlcmd script from SQL envriornment

Else you can use windows scheduler to execute the sqlcmd script file

Madhu

|||

I was hoping that we could run a sqlcmd script in a normal agent job, similar to the ability to run them in sql management studio window. The advantage of doing that is, the entire solution is in one place.

From your email it sounds as if, there is no way to do this and the only choice is to run a cmdshell agent job or to schedule in the Windows scheduler.

|||

In the Job Step Properties window, in the [General], click on [Type].

There you can select [Operation System ...]

Put your script there.

(

SQLCmd runs SQL commands in the OS environment,

CMDExec runs OS commands in the SQL Server environment -including SQLCmd.exe.

)

However, if you 'should' be able to directly run SQLCmd script as a Job step.

If you posted the command line, we may be able to better advise you about the most efficient method to accomplish your task.

No comments:

Post a Comment