Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

2

Share

MSSQL Server - Automation

MSSQL Server - Automation

Related Books

Free with a 30 day trial from Scribd

See all

MSSQL Server - Automation

  1. 1. Automation Ram Kedem
  2. 2. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent The What •SQL Server Agent enables you to automatethe execution of jobs. •SQL Server Agent jobs are collections of tasks known asjob steps. A step might be an activity such as taking a transaction log backup or copying data from one location to another.
  3. 3. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent The When •You can use SQL Server Agent to configure jobs to run according to a schedule. •You can also configure SQL Server Agent so that specific eventstrigger the execution of jobs.
  4. 4. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent The How •The SQL Server Agent service is disabled by default on SQL Server 2012Database Engine instances. You can start SQL Server Agent by right-clicking SQL Server Agent in SQL Server Management Studio and then choosing Start. •Startup Type-(auto / manual) can be configured using the configuration manager •Restart Behavior (Management Studio)–in case of the SQL Server service fails or if the SQL Server Agent service fails is configured by editing the properties of SQL Server Agent within SQL Server. •Each DatabaseEngineinstance has a separate SQL Server Agent.
  5. 5. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Account Windows Server Side •Although you can use the Local Systemor a local virtual accountfor the SQL Server Agent, this limits how the account can interact with resources external to the host server. •When choosing to use a domain-based security account, ensure that the account has the following permissions: •The logon as a service right. You assign this right by using Group Policy. •Membership of the Pre-Windows 2000 Compatible Access security group at the domain level. •Win7-Control Panel / System & Security / Local Security Poliy •a virtual account using the instance name as the service name is using the following formatNT SERVICE<SERVICENAME>. •Services that run as virtual accounts access network resources by using the credentials of the computer account in the format<domain_name><computer_name>$.
  6. 6. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Account •SQL Server Side •The account used for the SQL Server Agent service must be a member of the sysadminfixed server role. •If a user is not a member of the sysadminfixed server role, he or she must be a member of one or more of the following fixed database roles in the msdbdatabase to use SQL Server Agent: •SQLAgentUserRoleRole members have permissions only on the local jobsand job schedules they own. This role does not allow use of multi-server jobs. •SQLAgentReaderRoleThis role includes all the permissions assigned to the •SQLAgentUserRole. In addition, members of this role can view the properties and history of all available jobs and job schedules, including multi-server jobs. •SQLAgentOperatorRoleThis role includes all the permissions assigned to the SQLAgentReaderRole. In addition, members of this role can execute, stop, or start all local jobs and delete job history for any local job. Members can also enable and disable all local jobs and schedules.
  7. 7. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Mail Profile
  8. 8. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Mail Profile
  9. 9. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Mail Profile
  10. 10. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Configuring SQL Server Agent Mail Profile •Gmail details : smtp.gmail.com 587 •Make sure at least one profile is Global & Set to default •Make sure to restart SQL Server Agent before sending test Email. •Make sure your antivirus is disabled !
  11. 11. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Setting Up the SQL Server Agent Error Log •The SQL Server Agent error log stores warnings and error messages from SQL Server Agent. •You can configure the SQL Server Agent error log to store informational •events by choosing Information in the Agent log–level category in the error log •properties •Up to nine error logs are maintained.
  12. 12. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Setting Up the SQL Server Agent Error Log •Use the following command in order to manually recycle the error log: •By default, the error log is located at Program FilesMicrosoft SQLServerMSSQL.nMSSQLLOGERRORLOG EXECsp_cycle_errorlogGO
  13. 13. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Managing Alerts •In case you want the ability to send an email as a response for alert, first you must configure the SQL Server Agent and activate this option under the “Alert System” in its properties. •Restart to the agent must follows.
  14. 14. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Alert Types •Based on Severity / Error number •Alerts are only capture-able for errors that goes to the eventlog, which by default only a small amount of the system errors does. You can see what errors goes to eventlogin sys.messages. •You can change whether a specific error should be written to the eventlogusing sp_altermessage SQL Server Performance condition Alerts based on some performance issue (such as Locks / FTS etc.)
  15. 15. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Severity Based Alert
  16. 16. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Error Number Based Alert
  17. 17. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Performance Based Alert
  18. 18. Copyright 2014 © Ram Kedem. All rights reserved. Not to be reproduced without written consent Managing Jobs •Database administrators use jobs to automate routine tasks such as index maintenance or database backup. •When you configure a job, you : •Build a collection of job steps=> •such as TSQL / OS Commands •each job step can use a different execution type •add a schedule=> •choose appropriate alerts and notifications.
  • BehzadMohammadmirza

    Mar. 12, 2020
  • MeleAbza

    Sep. 28, 2016

MSSQL Server - Automation

Views

Total views

858

On Slideshare

0

From embeds

0

Number of embeds

380

Actions

Downloads

4

Shares

0

Comments

0

Likes

2

×