Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 set up a job to run query file

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2006-09-20 : 09:20:59
I save a query file in d:\test.sql.
Can I add a job to run this file at mid-night?
I knew how to run sp using "exec sp_name" but do not know which commmand to run test.sql.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-09-20 : 09:40:54
One option:
create a job step of type "Operating System Command (CmdExec)" and use an OSQL command to run the script file.
(see Books Online for OSQL)

Be One with the Optimizer
TG

EDIT:
here is an example of an OSQL call:

osql -E -n -i "d:\SQLScripts\myScript.sql" -o "d:\SQLScripts\myScript.log" -b
Go to Top of Page
   

- Advertisement -