SQL Server Agent
Note that this tutorial was written for those using the 2000 edition of SQL Server (SQL Server 2000). For later versions of SQL Server, check out the SQL Server 2008 tutorial and SQL Server 2014 tutorial.
The SQL Server Agent is a service that lets you configure scheduled tasks and system alerts. SQL Server Agent runs continuously in the background as a Windows Service.
The SQL Server Agent is made up of the following components:
|Jobs||SQL jobs consist of one or more steps to be executed. Each step consists of a SQL statement. SQL Agent Jobs can be scheduled to run at specified times or at specified intervals.|
|Alerts||SQL Alerts consist of a set of actions to occur when a specific event occurs (such as when a particular error occurs, or the database reaches a defined size). Alerts can include sending an email to the administrator, paging the administrator, or running a job to fix the problem.|
|Operators||Operators are people who can address problems with SQL Server. Operators can be identified through their network account or their email identifier. These are usually the people who alerts are sent to.|
SQL Agent Configuration
Behind the scenes, SQL Agent Job definitions are specified in the msdb database. You might remember the msdb database from a previous lesson. It is a system database that is created when you first install SQL Server.
You don't really need to know that in order to use the SQL Agent Service though. You can configure SQL Server Agent jobs, alerts and operators via Enterprise Manager. Applications that use SQL-DMO or Transact-SQL with a standard database API can also do this, but for now, we'll stick with Enterprise Manager.
Starting the SQL Server Agent
You can start and stop the SQL Server Agent Service via Enterprise Manager, the Windows Services console, or via the SQL Server Service Manager. More on the Service Manager later, but for now, you should know that you need to have the SQL Server Agent Service running before any scheduled jobs can be run or alerts can sent.
To start the SQL Server Agent Service via Enterprise Manager, right click on the "SQL Service Agent" node, and click "Start":
Now that SQL Server Agent is running, any jobs or alerts that you create will automatically run when they're supposed to.