Configuring SQL Server Agent Properties Executing jobs based on resource availability Idle CPU Condition When to restart SQL Server Agent Auto restart SQL Server (Recommended) Auto restart SQL Server Agent (Recommended) How much information to persist in the error log Include Execution Trace Messages(check disk space) Alerts and notifications
SQL Server Agent Job Schedule Operator Alert Proxy
Configuring Jobs A job is a specified series of operations performed sequentially by SQL Server Agent. A job can perform a wide range of activities, including running Transact-SQL scripts, command-line applications, Microsoft ActiveX scripts, Integration Services packages, Analysis Services commands and queries, or Replication tasks. Jobs can run repetitive tasks or those that can be scheduled, and they can automatically notify users of job status by generating alerts, thereby greatly simplifying SQL Server administration. *
SQL Server Agent SQL Server Integration Services (SSIS) packages T-SQL scripts PowerShell scripts ActiveX scripts Replication tasks Analysis Services tasks Operating system task (CmdExec)
Only members of the sysadmin fixed server role can create operators. SQLAgentUserRole SQLAgentReaderRole SQLAgentOperatorRole Note that SQL Server Agent must be configured to use Database Mail to send e-mail and pager notifications to operators. The Pager and net send options will be removed from SQL Server Agent in a future version of Microsoft SQL Server. Avoid using these features in new development work, and plan to modify applications that currently use these features.
Creating Operators -- sets up the operator information for user 'danwi.' The operator is enabled. -- SQL Server Agent sends notifications by pager from Monday through Friday from 8 A.M. to 5 P.M. USE msdb ; GO EXEC dbo.sp_add_operator @name = N'Dan Wilson', @enabled = 1, @email_address = N'danwi', @pager_address = N'5551290AW @pager.Adventure-Works.com', @weekday_pager_start_time = 080000, @weekday_pager_end_time = 170000, @pager_days = 62 ; GO
Creating Alerts Alerts are automated notifications that are fired when certain events are triggered. SQL Server event SQL Server performance conditions Windows Management Instrumentation(WMI) event Windows Management Instrumentation (WMI) is the infrastructure for management data and operations on Windows-based operating systems. You can write WMI scripts or applications to automate administrative tasks on remote computers but WMI also supplies management data to other parts of the operating system and products, for example System Center Operations Manager, formerly Microsoft Operations Manager (MOM), or Windows Remote Management (WinRM).WinRM
USE msdb EXEC sp_add_alert @name = 'Test Alert', @message_id = 55001, @severity = 0, @notification_message = 'Error 55001 has occurred. The database will be backed up...', @job_name = 'Back up the Customer Database'
Creating Alerts -- adds an e-mail notification for the specified alert (Test Alert) -- This example assumes that Test Alert already exists and that François Ajenstat is a valid operator name. USE msdb ; GO EXEC dbo.sp_add_notification @alert_name = N'Test Alert', @operator_name = N'François Ajenstat', @notification_method = 1 ; GO
Creating Proxies A SQL Server Agent proxy defines the security context for a job step. A proxy provides SQL Server Agent with access to the security credentials for a Microsoft Windows user. Each proxy can be associated with one or more subsystems. A job step that uses the proxy can access the specified subsystems by using the security context of the Windows user. Before SQL Server Agent runs a job step that uses a proxy, SQL Server Agent impersonates the credentials defined in the proxy, and then runs the job step by using that security context.
Creating Credentials Credentials provide a way to allow SQL Server Authentication users to have an identity outside of SQL Server. Credentials can also be used when a SQL Server Authentication user needs access to a domain resource, such as a file location to store a backup A credential can be mapped to several SQL Server logins at the same time. A SQL Server login can only be mapped to one credential at a time.