Monday, March 26, 2012

Running a batch command using scheduler

Hi,

I have a batch file that runs an isql script. The sql accepts command line arguments as parameters. I want to invoke this batch file using windows scheduler. How do I pass parameters to my sql? Somebody please help.

Thanks.

I am not sure about the batch file idea, but SQL server has a job scheduler built in called sql agent. You would be much better using this to call a stored procedure and pass in the arguments. To get you started, try this:

http://msdn2.microsoft.com/en-us/library(d=robot)/ms189237.aspx

Otherwise, why not replace your batch file with a .NET console application that takes command line parameters and passes them to a stored procedure call. Batch files are old, and while they still have some uses, there are much better ways of achieving what you are trying to do in an easier way, which gives you more power and flexibility.

There is a way to run sql scripts from the commandline using an exe supplied with sql server. For information on this, check out:

http://msdn2.microsoft.com/en-us/library/ms170207.aspx

HTH

For more T-SQL tips, check out my home page:|||Thanks for the reply :)

No comments:

Post a Comment