Ad-Hoc Maintenance Plans for Beginners

Hungarian Microsoft SQL Server User Group | November 2013 Meetup
Lengyel-magyar két jó barát, együtt harcol s issza borát
SELECT {BIO}
Polish SQL Server User Group Leader
Microsoft Certified Trainer
MCP, MCSA, MLSS, MLSBS, MCTS, MCITP, MCT
SQL Server MVP from 2010
Friends of RedGate PLUS
PASS SQL Azure Virtual Chapter Co-Founder
Blogger, Influencer, Technical Writer
Last 8 years (living) in Data Center in Wrocław
Generally about 14 years in IT/banking area
GITCA Technical Lead & Vice-Chair EMEA Board
Speaker at SQL Server Community Launch, Time for SharePoint, CodeCamps, SharePoint
Community Launch, CISSP Day, InfoTRAMS, SQLSaturday, SQLBits, CarreerCon, SQL Rally
Autor of few articles on TechNet (PL) and WSS.pl portal
Deep Dives Co-Author:
High availability of SQL Server in the context
of Service Level Agreements (Chapter 18th)
Technical reviewer:
Exploring MDX in SQL Server 2012
Working for Microsoft Subject Matter Expert and Terminology Community
(Windows 7, 8 & Visualstudio 2010,2012)

3
AGENDA
Maintenance Plans – what are you talking about?
Maintenance Plans – how, where, when?
• Methods, tools, right (?) ways
What Maintenance Plans can do you You
• Back Up Database
• Verify Integrity of Database
• Maintain a Database Indexes
• Maintain Index & Column Statistics
• Remove Older Data from msdb
• Remove Old Backups
Examples
Q&A

Budapest | November 27th, 2013

4
Maitenance Plans
– what are you talking about?

Budapest | November 27th, 2013

5
MAINTENANCE PLANS – WHAT ARE YOU TALKING ABOUT?
•
•
•
•

Clean Environment
Silence
Knowledge about environment
Productivity / Performance

DEFINITION:
A database maintenance plan is a set of specific, proactive task
that need to be performer regularly on databases to ensure
their adequate performance and availability

Budapest | November 27th, 2013

6
Maintenance Plans
– how, where, when?

Budapest | November 27th, 2013

7
MAINTENANCE PLANS – HOW, WHERE, WHEN?
HOW:
• Maintenance Plan Wizard
• Maintenance Plan Designer
• T-SQL Scripts
• PowerShell Scripts
WHERE
• SQL Server Management Studio from Standard and above
• See you in… Express
WHEN:
• BEFORE: problems / service windows
• AFTER: maintaining / clients back to home

Budapest | November 27th, 2013

8
HOW: MAINTENANCE PLAN WIZARD
•
•
•
•
•

Very simple (although advanced) wizard
Providing possibility for creation simple task in dozens of seconds
Enough in many cases, environments
Limited but huge number of options
Limitations:
• number of databases
• granularity
• single tasks / no multitasking
• no scripting for another instances
• some known problems in previous version of SQL Server
o SQL Server 2005 Service Pack 2
o SQL Server 2008

Budapest | November 27th, 2013

9
HOW: MAINTENANCE PLAN DESIGNER
•
•
•
•

More flexible and advanced tool (not on this session)
Graphical user interface with SSIS
Most often used for „really DBA”
Increased features
• Workflow for specified tasks with execution plan
• Multitasking
• Two additional Maintenance plans
o Execute T-SQL Statement
o Notify Operator

Budapest | November 27th, 2013

10
LIMITATIONS: MAINTENANCE PLAN WIZARD & DESIGNER
• Limitations for both tools / those ideas are not possible
• Identification and removing fragmentation for physical files
• Identification abandoned, duplicated, forgotten indexes
• Providing backup on demand
• Werification good quality of backup
• Werification succesful restore
• Monitoring of performance
• Monitoring of SQL OS
• Monitoring of Windows OS
• Monitoring available space

Budapest | November 27th, 2013

11
MAINTENANCE PLAN: T-SQL & POWERSHELL SCRIPTS
• Functionality for „Real *Tru* DBA”
• Necessary for working with multiple databases, instances, server farms
• Feauters for scripting:
• Access to OS
• Posibility of moving
• Scripts sharing

One of the best examples and tools for free:
HTTP://OLA.HALLENGREN.COM/

Budapest | November 27th, 2013

12
What Maintenance Plans can do you You

Budapest | November 27th, 2013

13
MAINTENANCE PLANS: AVAILABLE TASKS
• Check Database Integrity
• DBCC CHECKDB

• Shrink Database

• NEVER, NEVER, NEVER

• Reorganize Index

• ALTER INDEX , and next Update Statistics

• Rebuild Index

• ALTER INDEX, Update Statistics are not necessary

• Update Statistics
• Sp_updatestats

• History Cleanup

• Using msdb, don’t do that too much frequently

• Execute SQL Server Agent Job

• Providing scrip using wen You work with agent

• Back Up Database (Full)

• Executing BACKUP DATABASE with FULL option, and next Transaction Log

• Back Up Database (Differential)

• Executing BACKUP DATABASE with DIFFERENTIAL option

• Back Up Database (Transaction Log)
• Executing BACKUP LOG, frequency...

• Maintenance Cleanup Task

• Most complicated feature ? BAK, TRN, TXT

Budapest | November 27th, 2013

14
FUNCTIONALITY: VERIFY INTEGRITY OF DATABASE
YOU SHOULD REMEMBER
• using DBCC CHECKDB
• Daily
• Weekly
• Monthly
• DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS
• Suppresses all informational messages.

• DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS, ALL_ERRORMSGS
• Displays all reported errors per object. All error messages are displayed by default. Specifying or
omitting this option has no effect. Error messages are sorted by object ID, except for those
messages generated from tempdb database.
• In SQL Server Management Studio, the maximum number of error messages returned is 1000.

• DBCC CHECKDB (’database_name’) NOINDEX
• Specifies that intensive checks of nonclustered indexes for user tables should not be performed.
This decreases the overall execution time. NOINDEX does not affect system tables because
integrity checks are always performed on system table indexes

Budapest | November 27th, 2013

15
POSSIBILITIES: SHRINK DATABASE
YOU SHOULD REMEMBER
NEVER USE THIS OPTION IN MAINTENACE PLANS
MDF & LDF
100 GB reserved
15 GB in use
DBCC SHRINKDATABASE
or
• DBCC SHRINKFILE | MANUAL MODE
•
•
•
•

Reduction of Reserved Space

Budapest | November 27th, 2013

16
POSSIBILITIES: MAINTAIN INDEX & COLUMN STATISTICS
YOU SHOULD REMEMBER
Automation:
• AUTO_CREATE_STATISTICS
• AUTO_UPDATE_STATISTICS
• Executing automatically after: INSERT, UPDATE, DELETE
• UPDATE STATISTICS table_name WITH FULLSCAN

When:
• Never…
• Just after Index Reorganization
• On the days when we’re not using Index Rebuild or Reorganize Index
Important options (UPDATE STATISTICS):
• All existing statistics
• Column statistics only
• Index statistics only
Budapest | November 27th, 2013

17
POSSIBILITIES: REORGANIZE VS REBUILD

18
POSSIBILITIES: HISTORY CLEAN UP (MSDB)
Choosing the data (right data) for deleting:
• Backup and restore history
• SQL Server Agent job history
• Maintenance Plan history

Budapest | November 27th, 2013

19
Summary

Budapest | November 27th, 2013

20
• We should remember about:
• Task sequences
• Task execution
• Task priority

• Documentation
• Using: daily / weekly / occasionally

• Better expoloration of our environment
• Monitoring (partially) of performance

• Standard and above (sorry)
• Maintenance Plan Wizard
• for beginners and small installations

• Maintenance Plan Designer
• Adult  , more complicated, wide environment
Budapest | November 27th, 2013

21
LINKS
• Brad McGehee | Brad’ Sure Guide to SQL Server Maintenance Plans
„My new eBook, Brad’ Sure Guide to SQL Server Maintenance Plans is now available as
a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who
want to learn how to properly create Maintenance Plans using the tools that come with
SQL Server Management Studio (SSMS) in SQL Server 2005/2008.
LINK: http://bit.ly/1ijdnah

• Ola Hallengreen | Maintenance Plans Scripts PASS slidedeck
„The SQL Server Maintenance Solution comprises scripts for running backups,
integrity checks, and index and statistics maintenance on all editions of Microsoft
SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012. The
solution is based on stored procedures, sqlcmd utility, and SQL Server Agent jobs”
LINK: http://bit.ly/1b220Ns

Budapest | November 27th, 2013

22
AFTER HOURS
•
•
•
•

MAIL: KoprowskiT@windowslive.com
MSG: KoprowskiT@windowslive.com
SKYPE: tjkoprowski
TWITTER/FACEBOOK/LINKEDIN: KoprowskiT
BLOGS:
ITPRO Anorak’s Vision: http://itblogs.pl/notbeautifulanymore/ [PL/EN]
Volume Licensing Specialites: http://koprowskit.eu/licensing/ [PL]
My MVP Blog: http://koprowskit.eu/geek/ [PL/EN/ES]

23
THANK YOU
AND DON’T FORGET ABOUT
1ST MARCH 2014

Budapest | November 27th, 2013

24

More Related Content

PDF
Plany Konserwacji SQL Server dla żółtodziobów
PPTX
working with sql server agent-2
PPTX
DAC 2012
PPTX
Adi Sapir ISUG 123 11/10/2012
PPTX
Products.intro.forum version
PPTX
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
PPTX
Bringing DevOps to the Database
PPTX
Manageability Enhancements of SQL Server 2012
Plany Konserwacji SQL Server dla żółtodziobów
working with sql server agent-2
DAC 2012
Adi Sapir ISUG 123 11/10/2012
Products.intro.forum version
SQL Explore 2012 - Tzahi Hakikat and Keren Bartal: Extended Events
Bringing DevOps to the Database
Manageability Enhancements of SQL Server 2012

What's hot (20)

PPTX
Microsoft sql server database administration
PDF
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
PPTX
Moving Windows Applications to the Cloud
PDF
Introduction to SQL Server Analysis services 2008
PPTX
ETL in data warehouse as a service enviornment
PPTX
SQL Server Deployments made easy with DACPAC
PPTX
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
PDF
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
PPTX
The Essentials of Building Cloud-Based Web Apps with Azure
PDF
KoprowskiT - SQLBITS X - 2am a disaster just began
PDF
Azure Boot Camp 21.04.2018 SQL Server in Azure Iaas PaaS on-prem Lars Platzdasch
PDF
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
PPTX
Reduce latency and boost sql server io performance
PPTX
SUSE Webinar - Introduction to SQL Server on Linux
PDF
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
PDF
Tech ED 2014 Running Oracle Databases and Application Servers on Azurev1
PPT
Sql implementations
PDF
KoprowskiT_SQLRelayCaerdydd_SQLSecurityInTheClouds
PDF
KoprowskiT_SQLRelay2014#8_Birmingham_FromPlanToBackupToCloud
PPTX
LVOUG meetup #2 - Forcing SQL Execution Plan Instability
Microsoft sql server database administration
KoprowskiT_SQLRelay2014#4_Caerdydd_MaintenancePlansForBeginners
Moving Windows Applications to the Cloud
Introduction to SQL Server Analysis services 2008
ETL in data warehouse as a service enviornment
SQL Server Deployments made easy with DACPAC
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
KoprowskiT_Session2_SDNEvent_SourceControlForDBA
The Essentials of Building Cloud-Based Web Apps with Azure
KoprowskiT - SQLBITS X - 2am a disaster just began
Azure Boot Camp 21.04.2018 SQL Server in Azure Iaas PaaS on-prem Lars Platzdasch
SQLDay2013_Denny Cherry - SQLServer2012inaHighlyAvailableWorld
Reduce latency and boost sql server io performance
SUSE Webinar - Introduction to SQL Server on Linux
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Tech ED 2014 Running Oracle Databases and Application Servers on Azurev1
Sql implementations
KoprowskiT_SQLRelayCaerdydd_SQLSecurityInTheClouds
KoprowskiT_SQLRelay2014#8_Birmingham_FromPlanToBackupToCloud
LVOUG meetup #2 - Forcing SQL Execution Plan Instability
Ad

Similar to KoprowskiT_HUG-MSSQL_AdHocMaintenancePlansForBeginners (20)

PDF
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
PDF
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
PDF
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
PDF
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
PPTX
HOPEX V2R1 : Database maintenance tasks
PPT
Managing SQLserver
PPTX
Managing SQLserver for the reluctant DBA
PPTX
Database Maintenance Optimization Brad Mc Gehee
PPT
Supporting SQLserver
PPTX
Top 10 DBA Mistakes on Microsoft SQL Server
PPSX
database_maintenance sequential plot.ppsx
PDF
Mcts self paced training kit exam 432 sql server 2008 - implementation and ...
PPTX
Dba101
PPTX
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
PDF
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
PDF
Configuring sql server - SQL Saturday, Athens Oct 2014
PPTX
Sql Automation 20090610
PPTX
How not to be a cranky dba
PPT
SQL Server Basics Hello world iam here.ppt
PDF
How to manage and monitor large sql server estates
KoprowskiT_SQLSaturday409_MaintenancePlansForBeginners
KoprowskiT_SQLSat409_MaintenancePlansForBeginners
SQLSaturday#290_Kiev_AdHocMaintenancePlansForBeginners
KoprowskiT_SQLRelay2014#2_Southampton_MaintenancePlansForBeginners
HOPEX V2R1 : Database maintenance tasks
Managing SQLserver
Managing SQLserver for the reluctant DBA
Database Maintenance Optimization Brad Mc Gehee
Supporting SQLserver
Top 10 DBA Mistakes on Microsoft SQL Server
database_maintenance sequential plot.ppsx
Mcts self paced training kit exam 432 sql server 2008 - implementation and ...
Dba101
Geek Sync | How to Be the DBA When You Don't Have a DBA - Eric Cobb | IDERA
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
Configuring sql server - SQL Saturday, Athens Oct 2014
Sql Automation 20090610
How not to be a cranky dba
SQL Server Basics Hello world iam here.ppt
How to manage and monitor large sql server estates
Ad

More from Tobias Koprowski (20)

PDF
KoprowskiT_2AMaDisasterJustBeganAD2018
PDF
DataMindsConnect2018_SECDEVOPS
PDF
KoprowskiT_SQLDay2016_2AMaDisasterJustBegan
PDF
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
PDF
KoprowskiT-Difinify2017-SQL_Security_In_The_Cloud
PDF
KoprowskiT_PASSEastMidsFEB16_2AMaDisasterJustBegan
PDF
KoprowskiT_SQLAzureLandingInBelfast
PDF
KoprowskiT_SQLSatMoscow_2AMaDisaterJustBegan
PDF
KoprowskiT_SQLSatMoscow_WASDforBeginners
PDF
KoprowskiT_SQLRelayBirmingham_SQLSecurityInTheClouds
PDF
KoprowskiT_SQLRelayNottingham_BackupAndRestoreAD2015
PDF
KoprowskiT_SBIPTI_Keynote
PDF
KoprowskiT_SQLSatHolland_SQLServerSecurityInTheCloud
PDF
KoprowskiT_SQLSatDenmark_WASDforBeginners
PDF
KoprowskiT_session1_SDNEvent_WASDforBeginners
PDF
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
PDF
KoprowskiT_SPBizConf_2AMaDisasterJustBegan
PDF
KoprowskiT_InfoTRAMS_TrustThePrimer
PDF
KoprowskiT_SQLSat419_WADBforBeginners
PDF
KoprowskiT_SPBizConference_2AMaDisasterJustBegan
KoprowskiT_2AMaDisasterJustBeganAD2018
DataMindsConnect2018_SECDEVOPS
KoprowskiT_SQLDay2016_2AMaDisasterJustBegan
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_Security_In_The_Cloud
KoprowskiT_PASSEastMidsFEB16_2AMaDisasterJustBegan
KoprowskiT_SQLAzureLandingInBelfast
KoprowskiT_SQLSatMoscow_2AMaDisaterJustBegan
KoprowskiT_SQLSatMoscow_WASDforBeginners
KoprowskiT_SQLRelayBirmingham_SQLSecurityInTheClouds
KoprowskiT_SQLRelayNottingham_BackupAndRestoreAD2015
KoprowskiT_SBIPTI_Keynote
KoprowskiT_SQLSatHolland_SQLServerSecurityInTheCloud
KoprowskiT_SQLSatDenmark_WASDforBeginners
KoprowskiT_session1_SDNEvent_WASDforBeginners
KoprowskiT_SQLSaturdayManchester_2AMaDisasterJustbegan
KoprowskiT_SPBizConf_2AMaDisasterJustBegan
KoprowskiT_InfoTRAMS_TrustThePrimer
KoprowskiT_SQLSat419_WADBforBeginners
KoprowskiT_SPBizConference_2AMaDisasterJustBegan

Recently uploaded (20)

PDF
Statistics on Ai - sourced from AIPRM.pdf
PDF
STKI Israel Market Study 2025 version august
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
DOCX
search engine optimization ppt fir known well about this
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
Microsoft Excel 365/2024 Beginner's training
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Architecture types and enterprise applications.pdf
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Five Habits of High-Impact Board Members
Statistics on Ai - sourced from AIPRM.pdf
STKI Israel Market Study 2025 version august
The influence of sentiment analysis in enhancing early warning system model f...
Taming the Chaos: How to Turn Unstructured Data into Decisions
A contest of sentiment analysis: k-nearest neighbor versus neural network
search engine optimization ppt fir known well about this
Basics of Cloud Computing - Cloud Ecosystem
Final SEM Unit 1 for mit wpu at pune .pptx
Getting started with AI Agents and Multi-Agent Systems
Microsoft Excel 365/2024 Beginner's training
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Architecture types and enterprise applications.pdf
sbt 2.0: go big (Scala Days 2025 edition)
Custom Battery Pack Design Considerations for Performance and Safety
Convolutional neural network based encoder-decoder for efficient real-time ob...
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
Flame analysis and combustion estimation using large language and vision assi...
Credit Without Borders: AI and Financial Inclusion in Bangladesh
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Five Habits of High-Impact Board Members

KoprowskiT_HUG-MSSQL_AdHocMaintenancePlansForBeginners

  • 1. Ad-Hoc Maintenance Plans for Beginners Hungarian Microsoft SQL Server User Group | November 2013 Meetup
  • 2. Lengyel-magyar két jó barát, együtt harcol s issza borát
  • 3. SELECT {BIO} Polish SQL Server User Group Leader Microsoft Certified Trainer MCP, MCSA, MLSS, MLSBS, MCTS, MCITP, MCT SQL Server MVP from 2010 Friends of RedGate PLUS PASS SQL Azure Virtual Chapter Co-Founder Blogger, Influencer, Technical Writer Last 8 years (living) in Data Center in Wrocław Generally about 14 years in IT/banking area GITCA Technical Lead & Vice-Chair EMEA Board Speaker at SQL Server Community Launch, Time for SharePoint, CodeCamps, SharePoint Community Launch, CISSP Day, InfoTRAMS, SQLSaturday, SQLBits, CarreerCon, SQL Rally Autor of few articles on TechNet (PL) and WSS.pl portal Deep Dives Co-Author: High availability of SQL Server in the context of Service Level Agreements (Chapter 18th) Technical reviewer: Exploring MDX in SQL Server 2012 Working for Microsoft Subject Matter Expert and Terminology Community (Windows 7, 8 & Visualstudio 2010,2012) 3
  • 4. AGENDA Maintenance Plans – what are you talking about? Maintenance Plans – how, where, when? • Methods, tools, right (?) ways What Maintenance Plans can do you You • Back Up Database • Verify Integrity of Database • Maintain a Database Indexes • Maintain Index & Column Statistics • Remove Older Data from msdb • Remove Old Backups Examples Q&A Budapest | November 27th, 2013 4
  • 5. Maitenance Plans – what are you talking about? Budapest | November 27th, 2013 5
  • 6. MAINTENANCE PLANS – WHAT ARE YOU TALKING ABOUT? • • • • Clean Environment Silence Knowledge about environment Productivity / Performance DEFINITION: A database maintenance plan is a set of specific, proactive task that need to be performer regularly on databases to ensure their adequate performance and availability Budapest | November 27th, 2013 6
  • 7. Maintenance Plans – how, where, when? Budapest | November 27th, 2013 7
  • 8. MAINTENANCE PLANS – HOW, WHERE, WHEN? HOW: • Maintenance Plan Wizard • Maintenance Plan Designer • T-SQL Scripts • PowerShell Scripts WHERE • SQL Server Management Studio from Standard and above • See you in… Express WHEN: • BEFORE: problems / service windows • AFTER: maintaining / clients back to home Budapest | November 27th, 2013 8
  • 9. HOW: MAINTENANCE PLAN WIZARD • • • • • Very simple (although advanced) wizard Providing possibility for creation simple task in dozens of seconds Enough in many cases, environments Limited but huge number of options Limitations: • number of databases • granularity • single tasks / no multitasking • no scripting for another instances • some known problems in previous version of SQL Server o SQL Server 2005 Service Pack 2 o SQL Server 2008 Budapest | November 27th, 2013 9
  • 10. HOW: MAINTENANCE PLAN DESIGNER • • • • More flexible and advanced tool (not on this session) Graphical user interface with SSIS Most often used for „really DBA” Increased features • Workflow for specified tasks with execution plan • Multitasking • Two additional Maintenance plans o Execute T-SQL Statement o Notify Operator Budapest | November 27th, 2013 10
  • 11. LIMITATIONS: MAINTENANCE PLAN WIZARD & DESIGNER • Limitations for both tools / those ideas are not possible • Identification and removing fragmentation for physical files • Identification abandoned, duplicated, forgotten indexes • Providing backup on demand • Werification good quality of backup • Werification succesful restore • Monitoring of performance • Monitoring of SQL OS • Monitoring of Windows OS • Monitoring available space Budapest | November 27th, 2013 11
  • 12. MAINTENANCE PLAN: T-SQL & POWERSHELL SCRIPTS • Functionality for „Real *Tru* DBA” • Necessary for working with multiple databases, instances, server farms • Feauters for scripting: • Access to OS • Posibility of moving • Scripts sharing One of the best examples and tools for free: HTTP://OLA.HALLENGREN.COM/ Budapest | November 27th, 2013 12
  • 13. What Maintenance Plans can do you You Budapest | November 27th, 2013 13
  • 14. MAINTENANCE PLANS: AVAILABLE TASKS • Check Database Integrity • DBCC CHECKDB • Shrink Database • NEVER, NEVER, NEVER • Reorganize Index • ALTER INDEX , and next Update Statistics • Rebuild Index • ALTER INDEX, Update Statistics are not necessary • Update Statistics • Sp_updatestats • History Cleanup • Using msdb, don’t do that too much frequently • Execute SQL Server Agent Job • Providing scrip using wen You work with agent • Back Up Database (Full) • Executing BACKUP DATABASE with FULL option, and next Transaction Log • Back Up Database (Differential) • Executing BACKUP DATABASE with DIFFERENTIAL option • Back Up Database (Transaction Log) • Executing BACKUP LOG, frequency... • Maintenance Cleanup Task • Most complicated feature ? BAK, TRN, TXT Budapest | November 27th, 2013 14
  • 15. FUNCTIONALITY: VERIFY INTEGRITY OF DATABASE YOU SHOULD REMEMBER • using DBCC CHECKDB • Daily • Weekly • Monthly • DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS • Suppresses all informational messages. • DBCC CHECKDB (’database_name’) WITH NO_INFOMSGS, ALL_ERRORMSGS • Displays all reported errors per object. All error messages are displayed by default. Specifying or omitting this option has no effect. Error messages are sorted by object ID, except for those messages generated from tempdb database. • In SQL Server Management Studio, the maximum number of error messages returned is 1000. • DBCC CHECKDB (’database_name’) NOINDEX • Specifies that intensive checks of nonclustered indexes for user tables should not be performed. This decreases the overall execution time. NOINDEX does not affect system tables because integrity checks are always performed on system table indexes Budapest | November 27th, 2013 15
  • 16. POSSIBILITIES: SHRINK DATABASE YOU SHOULD REMEMBER NEVER USE THIS OPTION IN MAINTENACE PLANS MDF & LDF 100 GB reserved 15 GB in use DBCC SHRINKDATABASE or • DBCC SHRINKFILE | MANUAL MODE • • • • Reduction of Reserved Space Budapest | November 27th, 2013 16
  • 17. POSSIBILITIES: MAINTAIN INDEX & COLUMN STATISTICS YOU SHOULD REMEMBER Automation: • AUTO_CREATE_STATISTICS • AUTO_UPDATE_STATISTICS • Executing automatically after: INSERT, UPDATE, DELETE • UPDATE STATISTICS table_name WITH FULLSCAN When: • Never… • Just after Index Reorganization • On the days when we’re not using Index Rebuild or Reorganize Index Important options (UPDATE STATISTICS): • All existing statistics • Column statistics only • Index statistics only Budapest | November 27th, 2013 17
  • 19. POSSIBILITIES: HISTORY CLEAN UP (MSDB) Choosing the data (right data) for deleting: • Backup and restore history • SQL Server Agent job history • Maintenance Plan history Budapest | November 27th, 2013 19
  • 21. • We should remember about: • Task sequences • Task execution • Task priority • Documentation • Using: daily / weekly / occasionally • Better expoloration of our environment • Monitoring (partially) of performance • Standard and above (sorry) • Maintenance Plan Wizard • for beginners and small installations • Maintenance Plan Designer • Adult  , more complicated, wide environment Budapest | November 27th, 2013 21
  • 22. LINKS • Brad McGehee | Brad’ Sure Guide to SQL Server Maintenance Plans „My new eBook, Brad’ Sure Guide to SQL Server Maintenance Plans is now available as a free, 269 page PDF eBook. The book is designed for part-time or novice DBAs who want to learn how to properly create Maintenance Plans using the tools that come with SQL Server Management Studio (SSMS) in SQL Server 2005/2008. LINK: http://bit.ly/1ijdnah • Ola Hallengreen | Maintenance Plans Scripts PASS slidedeck „The SQL Server Maintenance Solution comprises scripts for running backups, integrity checks, and index and statistics maintenance on all editions of Microsoft SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012. The solution is based on stored procedures, sqlcmd utility, and SQL Server Agent jobs” LINK: http://bit.ly/1b220Ns Budapest | November 27th, 2013 22
  • 23. AFTER HOURS • • • • MAIL: [email protected] MSG: [email protected] SKYPE: tjkoprowski TWITTER/FACEBOOK/LINKEDIN: KoprowskiT BLOGS: ITPRO Anorak’s Vision: http://itblogs.pl/notbeautifulanymore/ [PL/EN] Volume Licensing Specialites: http://koprowskit.eu/licensing/ [PL] My MVP Blog: http://koprowskit.eu/geek/ [PL/EN/ES] 23
  • 24. THANK YOU AND DON’T FORGET ABOUT 1ST MARCH 2014 Budapest | November 27th, 2013 24