Sunteți pe pagina 1din 4

3/11/2014 SQL Server Backup, Integrity Check, Index and Statistics Maintenance

http://ola.hallengren.com/ 1/4
Menu
Home
SQLServerBackup
SQLServerIntegrityCheck
SQLServerIndexand
StatisticsMaintenance
Downloads
FrequentlyAskedQuestions
VersionHistory
OrganizationsthatUsethe
Solution
SignUpfortheNewsletter
License
Contact
Awards

SQLServerMaintenanceSolution
SQLServerBackup,IntegrityCheck,andIndex
andStatisticsMaintenance
TheSQLServerMaintenanceSolutioncomprisesscriptsforrunning
backups,integritychecks,andindexandstatisticsmaintenanceonall
editionsofMicrosoftSQLServer2005,SQLServer2008,SQLServer
2008R2,andSQLServer2012.Thesolutionisbasedonstored
procedures,thesqlcmdutility,andSQLServerAgentjobs.Idesigned
thesolutionforthemostmissioncriticalenvironments,anditisusedin
manyorganizationsaroundtheworld.NumerousSQLServer
communityexpertsrecommendtheSQLServerMaintenanceSolution,
whichhasbeenaGoldwinnerinthe2013,2012,2011,and2010SQL
ServerMagazineAwards.TheSQLServerMaintenanceSolutionisfree.
Thebeststartingpointforbuildingyourownmaintenanceplan
isthecomprehensiveandfreescriptfromOlaHallengren.Thats
whatIrecommendtomyclients.PaulS.Randal
GettingStarted
DownloadMaintenanceSolution.sql.Thisscriptcreatesalltheobjects
andjobsthatyouneed.
LearnmoreaboutusingtheSQLServerMaintenanceSolution:
DatabaseBackup:SQLServerBackup
DatabaseIntegrityCheck:SQLServerIntegrityCheck
IndexOptimize:SQLServerIndexandStatisticsMaintenance
Signupforthenewslettertobealertedaboutupdatestothesolution.
SQLServer2014CTP
MicrosofthasmadeaCommunityTechnologyPreview(CTP)version
availableofSQLServer2014.TheCTPversioncontainspartitionlevel
onlineindexrebuilds,lockprioritiesforonlineindexrebuilds,backup
encryption,andmanyotherfeatures.IhaveaCTPversionoftheSQL
ServerMaintenanceSolutionwithsupportforthesefeatures.Please
contactmetogettheCTPversion,ifyouaredoingtestingonSQL
Server2014.
SQLServer2012
TheSQLServerMaintenanceSolutionsupportsSQLServer2012.
OnenewfeatureinSQLServer2012isAlwaysOnAvailabilityGroups.
Thisfeaturesupportsmultiplereplicasofadatabase.Secondaryreplicas
3/11/2014 SQL Server Backup, Integrity Check, Index and Statistics Maintenance
http://ola.hallengren.com/ 2/4
Sponsors
canbereadableandtheycanalsobeusedforbackup.
SQLServer2012alsosupportsonlinerebuildingofindexeswith
varchar(max),nvarchar(max),varbinary(max),orXMLdatatypesor
largeCLRtypes.
IntelligentIndexMaintenance
TheSQLServerMaintenanceSolutionletsyouintelligentlyrebuildor
reorganizeonlytheindexesthatarefragmented.IntheIndexOptimize
procedure,youcandefineapreferredindexmaintenanceoperationfor
eachfragmentationgroup.Takealookatthiscode:
EXECUTEdbo.IndexOptimize@Databases='USER_DATABASES',
@FragmentationLow=NULL,
@FragmentationMedium=
'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh=
'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1=5,
@FragmentationLevel2=30
Inthisexample,indexesthathaveahighfragmentationlevelwillbe
rebuilt,onlineifpossible.Indexesthathaveamediumfragmentation
levelwillbereorganized.Indexesthathavealowfragmentationlevel
willremainuntouched.
UpdateStatistics
TheIndexOptimizeprocedurecanalsobeusedtoupdatestatistics.You
canchoosetoupdateallstatistics,statisticsonindexesonly,orstatistics
oncolumnsonly.Youcanalsochoosetoupdatethestatisticsonlyifany
rowshavebeenmodifiedsincethemostrecentstatisticsupdate.
EXECUTEdbo.IndexOptimize@Databases='USER_DATABASES',
@FragmentationLow=NULL,
@FragmentationMedium=
'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh=
'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1=5,
@FragmentationLevel2=30,
@UpdateStatistics='ALL',
@OnlyModifiedStatistics='Y'
SolveNoCurrentDatabaseIssues
MostDBAshaveexperiencedtheerrormessageBACKUPLOGcannotbe
performedbecausethereisnocurrentdatabasebackuporCannot
performadifferentialbackupfordatabase,becauseacurrentdatabase
backupdoesnotexist.Theseerrorsusuallyoccurwhenyouhave
createdanewdatabaseorchangedthedatabaserecoverymodelfrom
3/11/2014 SQL Server Backup, Integrity Check, Index and Statistics Maintenance
http://ola.hallengren.com/ 3/4
SimpletoFull.Theansweristodetermine,beforeyourunthebackup,
whetheradifferentialortransactionlogbackupcanbeperformed.You
canusetheDatabaseBackupprocedures@ChangeBackupTypeoptionto
changethebackuptypedynamicallyifadifferentialortransactionlog
backupcannotbeperformed.
Heresanexampleofhowtousethe@ChangeBackupTypeoption:
EXECUTEdbo.DatabaseBackup
@Databases='USER_DATABASES',
@Directory='C:\Backup',
@BackupType='LOG',
@Verify='Y',
@ChangeBackupType='Y',
@CleanupTime=24
BackuptoMultipleFiles
Databasesarebecominglargerandlarger.Youcantunethe
performanceofSQLServerbackupcompression,byusingmultiple
backupfiles,andtheBUFFERCOUNTandMAXTRANSFERSIZEoptions.
TheDatabaseBackupproceduresupportstheseoptions:
EXECUTEdbo.DatabaseBackup
@Databases='USER_DATABASES',
@Directory='C:\Backup,D:\Backup,E:\Backup,F:\Backup',
@BackupType='FULL',
@Compress='Y',
@BufferCount=50,
@MaxTransferSize=4194304,
@NumberOfFiles=4,
@CleanupTime=24
RunIntegrityChecksofVeryLargeDatabases
TheSQLServerMaintenanceSolutionhasbeendesignedtodointegrity
checksofverylargedatabases.IntheDatabaseIntegrityCheck
procedureyoucanchoosedothechecksonthedatabaselevel,the
filegrouplevel,orthetablelevel.Italsosupportslimitingthechecksto
thephysicalstructuresofthedatabase:
EXECUTEdbo.DatabaseIntegrityCheck
@Databases='USER_DATABASES',
@CheckCommands='CHECKDB',
@PhysicalOnly='Y'
SQLServerCommunityAwards
Forthepastfouryears,theSQLServerMaintenanceSolutionhasbeen
votedasBestFreeToolintheSQLServerMagazineAwards:
2014MicrosoftMostValuableProfessional(MVP)SQLServer
3/11/2014 SQL Server Backup, Integrity Check, Index and Statistics Maintenance
http://ola.hallengren.com/ 4/4
2014SimpleTalkandSQLServerCentralTribalAwards:Best
FreeScript
2013SQLServerMagazineCommunityChoice:BestFreeTool,
Goldaward
2012SQLServerMagazineCommunityChoice:BestFreeTool,
Goldaward
2011SQLServerMagazineEditorsBest:BestFreeTool,Silver
award
2011SQLServerMagazineCommunityChoice:BestFreeTool,
Goldaward
Handsdown,oneofthebesttoolsoutthere!Ifyoure
responsibleforadatabase,youshouldbeusingOlasscripts.Its
verycomprehensive,isefficientwithresources,hasnumerous
options,andisabrilliantpieceofSQLcoding!
2010SQLServerMagazineEditorsBest:BestFreeTool,Bronze
award
2010SQLServerMagazineCommunityChoice:BestFreeTool,
Goldaward
TheSolutionintheNewsandontheWeb
IhostedasessionabouttheSQLServerMaintenanceSolutionon
SQLBitsIX,inOctober2011.
SQLPASShadasessionabouttheSQLServerMaintenanceSolution
duringthe24HoursofPASS2010onlineconference.
SQLServerMagazinefeaturedanarticleabouttheSQLServer
MaintenanceSolutioninitsNovember2008issue(PDFversion).
SimpleTalkfeaturedanarticleabouttheSQLServerMaintenance
SolutioninJuly2010.
Feelfreetocontactmeifyouhaveanyquestions.Thankyoufortrying
outthesolution.
2013OlaHallengren|Email:ola@hallengren.com|Sweden

S-ar putea să vă placă și