Answered by:
Job to run outside script

Question
-
I have a script that is too long to cut and paste into a job, but I would still like to set it to run regularly. I'm pretty sure there is a way to create a job that uses sqlcmd or osql to run the .sql file. Thanks for any help in advance.
-KyleThursday, July 10, 2008 2:34 PM
Answers
-
kschlap wrote: I would prefer this way as the higher ups prefer not to create stored procedures on the server.
-KyleWhy dont the higher ups want stored procedures? By the way you are making this sound it seems like none of your code is wrapped in stored procedures. Do the higher ups realize the benefits of using sps?
Yes, you can accomplish what you want, with sqlcmd. Create a the sqlcmd command to grab the input file, with the -i switch. The job will use the operating system exec cmd to execute the command.
All the info you need on sqlcmd is here.
Thursday, July 10, 2008 3:05 PM
All replies
-
You can create a stored procedure that will execute the script and schedule the job to execute the stored procedure.
Thursday, July 10, 2008 2:36 PM -
I would prefer this way as the higher ups prefer not to create stored procedures on the server.
-KyleThursday, July 10, 2008 2:50 PM -
kschlap wrote: I would prefer this way as the higher ups prefer not to create stored procedures on the server.
-KyleWhy dont the higher ups want stored procedures? By the way you are making this sound it seems like none of your code is wrapped in stored procedures. Do the higher ups realize the benefits of using sps?
Yes, you can accomplish what you want, with sqlcmd. Create a the sqlcmd command to grab the input file, with the -i switch. The job will use the operating system exec cmd to execute the command.
All the info you need on sqlcmd is here.
Thursday, July 10, 2008 3:05 PM -
Thank you much, that information is greatly appreciated.
-KyleThursday, July 10, 2008 6:12 PM