To create a SQLServer2000 background scheduled job Task _php tutorial using the T_sql script

Source: Internet
Author: User
Author: Mechanesm Http://idoorsoft.51.net
In the application system of database, full use of the function of the backend server of the database can simplify the work of the client foreground, reduce the load of the network, make the whole system design more reasonable, facilitate the maintenance migration and upgrade, and the background planning task work is often used in many database applications. It is of course used in conjunction with stored procedures.
In SQL Server2000, you can manually set up a background scheduled task job in Enterprise Manager in a step-by-step manner, but it is cumbersome and inconvenient to publish, so this article gives you a way to create a job using T-SQL scripts.
The following three SQL Server2000 the stored procedures in the msdb system library are required to complete the job creation, before the SQLServerAgent service for the DB instance is opened, and the service is not started by default after SQL Server installation.
By the way, SQL Server has a clear "instance" concept in version 2000, there are no explicit instances in version 7.0, so a default instance is created when SQL Server2000 is installed by default, for compatibility with SQL Server 7.0. If you are creating an instance by default, the instance name is empty. Why You don't know what "instance" is? Individual to find some information to see, Oracel, Sybase have instances and table space, so I called SQL Server2000 before the SQL Server for the desktop database.
To get to the point, the step is "job"-〉 "job Schedule"-〉 "job step", as follows:
1. Use Sp_add_job to add new jobs performed by the SQLServerAgent service.
2. Create job schedule using Sp_add_jobschedule.
3. Use Sp_add_jobstep to add a step (action) to the job
The following is an example of a script in the bus terminal ticketing system, and before looking at the example, take a look at the help of the above three system stored procedures. In the example, a custom stored procedure "Tksp_bakdata" is used, and its function is to process the ticket data prior to the current day (just know that a custom stored procedure is OK).
Example 1: Daily 0:30 processing of ticket data
Www.knowsky.com
Use msdb
EXEC sp_add_job @job_name = ' Tk_bakdata ',
@enabled = 1,
@description = ' daily 00:30 processing of ticket data ',
@start_step_id = 1,
@owner_login_name = ' Tkuser '
exec sp_add_jobserver @job_name = ' Tk_bakdata '
Go
EXEC sp_add_jobschedule @job_name = ' Tk_bakdata ',
@name = ' Bakdata003000 ',
@freq_type = 4,
@freq_interval = 1,
@active_start_time = 003000
Go
EXEC sp_add_jobstep @job_name = ' Tk_bakdata ',
@step_name = ' Bakdata ',

http://www.bkjia.com/PHPjc/631226.html www.bkjia.com true http://www.bkjia.com/PHPjc/631226.html techarticle Author: mechanesm http://idoorsoft.51.net in the database application system, the full use of the database backend server function can simplify the work of the client front desk, but also reduce the network ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.