使用T_SQL脚本创建SQLServer2000后台计划作业任务
作者:蒋勇 http://idoorsoft.51.net
在数据库的应用系统中,充分的利用数据库的后台服务端的功能可以可以简化客户端前台的工作,更可以降低网络的负荷,同时使整个系统设计更合理,便于维护移植和升级,后台计划任务作业在很多数据库应用中经常会用到,当然是配合存储过程使用。
在SQL Server2000中,可以手动一步一步的在企业管理器中建立后台计划任务作业,但这样既麻烦也不便于发布,因此本文给出使用T-SQL脚本创建作业的方法。
需要下面三个SQL Server2000 msdb系统库中的存储过程来完成作业的建立,在此之前请先开启数据库实例的SQLServerAgent服务,SQL Server安装后默认是没有启动该服务的。
顺便说一句,SQL Server在2000版本中才有了明显的“实例”的概念,在7.0版中没有明确的实例,因此在SQL Server2000默认安装时创建了一个默认实例,这是为了和SQl Server 7.0兼容,如果你是默认方式创建的实例,则实例名为空。啥子?你不晓得啥子是“实例”?个人去找点资料看看,oracel、sybase都有实例和表空间,所以我叫SQL Server2000之前的SQL Server为桌面数据库。
进入正题,步骤是“作业”-〉“作业调度”-〉“作业步骤”,具体如下:
1、使用sp_add_job 添加由 SQLServerAgent 服务执行的新作业。
2、使用sp_add_jobschedule创建作业调度。
3、使用sp_add_jobstep将一个步骤(操作)添加到作业中
下面以在汽车客运站票务系统中的脚本为例给出实际例子,在看例子之前,请先看一下上面三个系统存储过程的帮助。在例子中使用了一个自定义的存储过程“tksp_bakdata”,它的功能是处理当日之前售票数据(只需知道是一个自定义存储过程就行了)。
例子1:每日0点30分处理售票数据
www.knowsky.com
use msdb
EXEC sp_add_job @job_name = 'tk_bakdata',
@enabled = 1,
@description = '每日00:30处理售票数据',
@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',

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension

Title: Realme Phone Beginner’s Guide: How to Create Folders on Realme Phone? In today's society, mobile phones have become an indispensable tool in people's lives. As a popular smartphone brand, Realme Phone is loved by users for its simple and practical operating system. In the process of using Realme phones, many people may encounter situations where they need to organize files and applications on their phones, and creating folders is an effective way. This article will introduce how to create folders on Realme phones to help users better manage their phone content. No.

Xiaomi car software provides remote car control functions, allowing users to remotely control the vehicle through mobile phones or computers, such as opening and closing the vehicle's doors and windows, starting the engine, controlling the vehicle's air conditioner and audio, etc. The following is the use and content of this software, let's learn about it together . Comprehensive list of Xiaomi Auto app functions and usage methods 1. The Xiaomi Auto app was launched on the Apple AppStore on March 25, and can now be downloaded from the app store on Android phones; Car purchase: Learn about the core highlights and technical parameters of Xiaomi Auto, and make an appointment for a test drive. Configure and order your Xiaomi car, and support online processing of car pickup to-do items. 3. Community: Understand Xiaomi Auto brand information, exchange car experience, and share wonderful car life; 4. Car control: The mobile phone is the remote control, remote control, real-time security, easy
