日期:2014-05-19  浏览次数:20525 次

怎么才能每天定时执行一个存储过程?
我做了一个存储过程,但是要求每天0:00执行这个过程,在Sqlserver用什么来做?

------解决方案--------------------
job
------解决方案--------------------
请在SQL Server代理中创建“作业”来实现该存储过程的调度计划。
------解决方案--------------------
If you have problems with SQL Server jobs, review this troubleshooting checklist to find potential solutions.

1. Check that you use the latest SQL Server service pack.

Because many bugs were fixed in SQL Server service packs, you should install the latest SQL Server service pack. To check what SQL Server service pack are you running, see this link: How can I check what SQL service pack am I running?

2. Check that Task Scheduler service is running.

This service must be started, if you need the job be scheduled. To start Task Scheduler service on Windows NT choose: Start -> Settings -> Control panel -> Services (choose Startup "Automatic " type) and Start.

To start Task Scheduler service on Windows 2000 choose: Start -> Settings -> Control panel -> Administrative Tools -> Services (choose Startup "Automatic " type) and Start.

3. Check that the SQLServerAgent and EventLog services are running, if all the jobs are not starting.

These services must be started, if you need the job be started. So, if these services are not running, you should run them.

4. Check that the account the SQLServerAgent services runs under is a member of the Domain Users group.

The LocalSystem account does not have network access rights, so if your jobs require resources across the network, or if you want to notify operators through e-mail or pagers, you must set the account the SQLServerAgent service runs under to be a member of the Domain Users group.

5. Check that the job is enabled, if the job is not starting.

The job can be enabled or disabled. To check that the job is enabled, you can do the following:

Run SQL Server Enterprise Manager.
Expand a server group; then expand a server.
Expand Management; then expand SQL Server Agent.
Double-click the appropriate job to see that the job enables.
6. If the job works fine when you start it manually, but does not start on the scheduled base, check that the job 's schedule is enabled.

The job schedule can be enabled or disabled. To check that the job schedule is enabled, you can do the following:

Run SQL Server Enterprise Manager.
Expand a server group; then expand a server.
Expand Management; then expand SQL Server Agent.
Double-click the appropriate job and choose the Schedules tab.
Double-click the appropriate job schedule to see that the job schedule is enable.
7. Check the history values of the job to determine the last date the job worked.

To view the history values of the job, you can do the following:

Run SQL Server Enterprise Manager.
Expand a server group; then expand a server.
Expand Management; then expand SQL Server Agent.
Right-click the appropriate job and choose 'View Job History '.
8. Check the SQL Server error log, SQL Server Agent error log, and Windows NT or Windows 2000 application log to get a more detailed error description.

Comparing the dates and times for alert failure events between the SQL Server error log, the SQL Server Agent error log, and the Windows NT or Windows 2000 application log can help you to determine the reason of the failure.

9. If the job works, but the responsible operator does not receive notification, try to send an 'e-mail ', 'pager ', or 'net send ' message to this operator manually