SlideShare une entreprise Scribd logo
1  sur  15
Automating Routine Maintenance Ken Simmons
Objectives Make informed decisions about the maintenance that must be performed within SQL Server. Enhance Proactive Administration by receiving Notifications for Job Failures and Alerts. Ensure consistency across your environment by performing routine system maintenance.
Agenda Configuring Database Mail Creating Alerts Creating An Administrative Database Configuring Maintenance Jobs Maintenance Considerations When Upgrading a Database
Why Do We Need To Perform Routine Maintenance?
Configuring Database Mail Enable Database Mail Create Profile  Create Account Create Operator Enable Database Mail in SQL Server Agent Enable Fail-Safe Operator
Creating Alerts Automated response to a predefined event Severity Codes   Fatal Errors19-25 Specific Error Numbers Error 825 – Severity 10 http://sqlskills.com/BLOGS/PAUL/post/A-little-known-sign-of-impending-doom-error-825.aspx
Creating Alerts (Cont) Non Fatal ErrorsSELECT * FROM sys.messagesWHERE language_id = 1033 ANDis_event_logged = 1 AND       severity < 19
Why Do You Need An Administrative Database? Provide central location for Administrative Tables, Functions, and Procedures Track Database Sizes for Capacity Planning Store DMV Output Holds the Nums or TallyTable http://www.sqlservercentral.com/articles/TSQL/62867/
What Maintenance Jobs Should You Be Running? Cycle the Error Log Make sure to increase the number of log files first. sp_cycle_errorlog Cleanup the Backup History Be careful if you havea lot of history. sp_delete_backuphistory Cleanup Mail History sysmail_delete_mailitems_sp sysmail_delete_log_sp
Maintenance Jobs (Cont) Update Statistics sp_updatestats  Index Maintenance > 5% and < = 30%    REORGANIZE > 30% REBUILD
Maintenance Jobs (Cont) Collect Database Sizes Check for long running jobs http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=AgentLongRunning&referringTitle=Home Check Database Integrity DBCC CHECKDB Backups Script Restore to file using backup history tables http://www.mssqltips.com/tip.asp?tip=1611 Make sure each job has an output file
Maintenance Jobs(Cont) Generate SQL Agent Job Schedule Report http://www.mssqltips.com/tip.asp?tip=1622
Maintenance Considerations When Upgrading a Database Change Database Compatibility Level ALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 100 Check the integrity of the objects in your database DBCC CHECKDB ([DatabaseName])  WITH DATA_PURITY Correct Row and Page Counts DBCC UPDATEUSAGE ([DatabaseName])  Set the page verification method to CHECKSUM ALTER DATABASE [DatabaseName] SET PAGE_VERIFY CHECKSUM WITH NO_WAIT Update Statistics With Full Scan sp_msforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'
Questions?
Links ,[object Object]

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Automating routine maintenance

  • 2. Objectives Make informed decisions about the maintenance that must be performed within SQL Server. Enhance Proactive Administration by receiving Notifications for Job Failures and Alerts. Ensure consistency across your environment by performing routine system maintenance.
  • 3. Agenda Configuring Database Mail Creating Alerts Creating An Administrative Database Configuring Maintenance Jobs Maintenance Considerations When Upgrading a Database
  • 4. Why Do We Need To Perform Routine Maintenance?
  • 5. Configuring Database Mail Enable Database Mail Create Profile Create Account Create Operator Enable Database Mail in SQL Server Agent Enable Fail-Safe Operator
  • 6. Creating Alerts Automated response to a predefined event Severity Codes Fatal Errors19-25 Specific Error Numbers Error 825 – Severity 10 http://sqlskills.com/BLOGS/PAUL/post/A-little-known-sign-of-impending-doom-error-825.aspx
  • 7. Creating Alerts (Cont) Non Fatal ErrorsSELECT * FROM sys.messagesWHERE language_id = 1033 ANDis_event_logged = 1 AND severity < 19
  • 8. Why Do You Need An Administrative Database? Provide central location for Administrative Tables, Functions, and Procedures Track Database Sizes for Capacity Planning Store DMV Output Holds the Nums or TallyTable http://www.sqlservercentral.com/articles/TSQL/62867/
  • 9. What Maintenance Jobs Should You Be Running? Cycle the Error Log Make sure to increase the number of log files first. sp_cycle_errorlog Cleanup the Backup History Be careful if you havea lot of history. sp_delete_backuphistory Cleanup Mail History sysmail_delete_mailitems_sp sysmail_delete_log_sp
  • 10. Maintenance Jobs (Cont) Update Statistics sp_updatestats Index Maintenance > 5% and < = 30% REORGANIZE > 30% REBUILD
  • 11. Maintenance Jobs (Cont) Collect Database Sizes Check for long running jobs http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=AgentLongRunning&referringTitle=Home Check Database Integrity DBCC CHECKDB Backups Script Restore to file using backup history tables http://www.mssqltips.com/tip.asp?tip=1611 Make sure each job has an output file
  • 12. Maintenance Jobs(Cont) Generate SQL Agent Job Schedule Report http://www.mssqltips.com/tip.asp?tip=1622
  • 13. Maintenance Considerations When Upgrading a Database Change Database Compatibility Level ALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 100 Check the integrity of the objects in your database DBCC CHECKDB ([DatabaseName]) WITH DATA_PURITY Correct Row and Page Counts DBCC UPDATEUSAGE ([DatabaseName]) Set the page verification method to CHECKSUM ALTER DATABASE [DatabaseName] SET PAGE_VERIFY CHECKSUM WITH NO_WAIT Update Statistics With Full Scan sp_msforeachtable 'UPDATE STATISTICS ? WITH FULLSCAN'
  • 15.

Notes de l'éditeur

  1. What works for one server may not be the best for another. You should be aware of the system maintenance that needs to be performed and how the decisions you make will impact your SQL Server.
  2. --The ALTER DATABASE statement replaces the sp_dbcmptlevel procedureALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 100--Adding the DATA_PURITY option causes the CHECKDB command to look for --column values that are invalid or out of range. Any database that was --created in SQL Server 2005 or later will include the DATA_PURITY check by default, --but if the database is being upgraded from an earlier version, you must run the --command with the DATA_PURITY option at least once and fix any issues. DBCC CHECKDB ([DatabaseName]) WITH DATA_PURITY--The DBCC UPDATEUSAGE command corrects inaccurate row and page counts for tables and indexes.DBCC UPDATEUSAGE ([DatabaseName])--When the CHECKSUM option is enabled, a checksum of the whole page is computed and stored in --the page header when the page is written to disk. When the page is read from disk, the --checksum is recalculated and compared with the value in the header.ALTER DATABASE [DatabaseName] SET PAGE_VERIFY CHECKSUM WITH NO_WAIT--Updating the statistics after the upgrade allows the database engine to take advantage of --the enhancements made in SQL Server 2008 to optimize query performance. The statistics --that reside in the database were created with an earlier version of SQL Server. --By recreating them with SQL Server 2008; you are allowing SQL Server to create more --intelligent statistics to work with. sp_msforeachtable &apos;UPDATE STATISTICS ? WITH FULLSCAN&apos;