locked
Job to run outside script RRS feed

  • 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. 
    -Kyle
    Thursday, 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.
    -Kyle

    Why 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.

    http://msdn.microsoft.com/en-us/library/ms162773.aspx

    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.
    -Kyle
    Thursday, 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.
    -Kyle

    Why 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.

    http://msdn.microsoft.com/en-us/library/ms162773.aspx

    Thursday, July 10, 2008 3:05 PM
  • Thank you much, that information is greatly appreciated.
    -Kyle
    Thursday, July 10, 2008 6:12 PM