How to schedule a script in SQL Server Express ( without SQL Server Agent )?

假装没事ソ 提交于 2019-12-05 05:13:19

问题


Ok so I asked a question yesterday about doing a timed procedure. I got some responses about using SQL Server Agent but i found out that I am using Sql server 2008 express RC and its not available.

Here is my first question and I want to know if there is another tool I can use to do a timed procedure with sql server ....thanks again


回答1:


You can use dialog timers to start activated procedures. This functionality is available on the Express edition. The advantage over an external service, like Windows Scheduler, is that the solution is self contained inside the database. For example you can move the database to a different computer and the timed procedure will still run, on the new computer, once the database is started. An external service requires you to reconfigure the scheduler agent on the new computer.




回答2:


You can use scheduled task (control panel-administrative tools) and start a .cmd/.bat file where you use sqlcmd to execute SP's or run scripts.

sqlcmd is a command line tool. sqlcmd /? will show you what you can do with it.

Here is how you can use sqlcmd to execute a SP called StoredProcName in database YourDatabase on server instance ComputerName\sqlexpress.

sqlcmd -S ComputerName\sqlexpress -E -d YourDatabase -Q "exec StoredProcName"

Read more about Using the sqlcmd Utility here http://msdn.microsoft.com/en-us/library/ms180944.aspx

Read about the Task Scheduler here http://msdn.microsoft.com/en-us/library/aa383614%28v=vs.85%29.aspx.



来源:https://stackoverflow.com/questions/5756516/how-to-schedule-a-script-in-sql-server-express-without-sql-server-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!