O'la! As in Ola Hallengren's SQL Server Backup, Integrity Check, and Index and Statistics Maintenance SQL scripts...
The Bit Bucket (Greg Low): IDisposable - Update of Ola Hallengren's Maintenance Tools (Still Free Too)
SQL Server 2008 R2 SP2 and SQL Server 2012 SP1 introduced sys.dm_db_stats_properties. This DMV is a new way to check the number of rows that have been modified since the last time a set of statistics was updated. It is described here: (http://msdn.microsoft.com/en-us/library/jj553546.aspx)
In the latest version of Ola's tools, he's made use of this new DMV for customers that are on one of these SQL Server versions. For customers on earlier versions, he continues to use sys.sysindexes in the same way he did previously.
Another notable change is that the new version works better when combined with log shipping on the same databases (avoids options that would break log shipping chains).
Ola's tools have been gaining a well-deserved reputation, particularly given the price (ie free).
SQL Server Maintenance Solution - SQL Server Backup, Integrity Check, and Index and Statistics Maintenance
"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, and SQL Server 2012. The solution is based on stored procedures, the sqlcmd utility, and SQL Server Agent jobs. I designed the solution for the most mission-critical enterprise environments, and it is used in many organizations around the world. Numerous SQL Server community experts recommend the SQL Server Maintenance Solution, which has been a Gold and Silver winner in the 2012, 2011, and 2010 SQL Server Magazine Awards. The SQL Server Maintenance Solution is free.
“Hands down, one of the best tools out there! If you’re responsible for a database, you should be using Ola’s scripts. It’s very comprehensive, is efficient with resources, has numerous options, and is a brilliant piece of SQL coding!” - SQL Server Magazine
Download MaintenanceSolution.sql. This script creates all the objects and jobs that you need.
Learn more about using the SQL Server Maintenance Solution:
- DatabaseBackup: SQL Server Backup
- DatabaseIntegrityCheck: SQL Server Integrity Check
- IndexOptimize: SQL Server Index and Statistics Maintenance
Intelligent Index Maintenance
The SQL Server Maintenance Solution lets you intelligently rebuild or reorganize only the indexes that are fragmented. In the IndexOptimize procedure, you can define a preferred index maintenance operation for each fragmentation group. Take a look at this code:
The IndexOptimize procedure can also be used to update statistics. You can choose to update all statistics, statistics on indexes only, or statistics on columns only. If an index is rebuilt, the statistics is not being updated. You can also choose to update the statistics only if any rows have been modified since the most recent statistics update.
Solve “No Current Database” Issues
Most DBAs have experienced the error message “BACKUP LOG cannot be performed because there is no current database backup” or “Cannot perform a differential backup for database, because a current database backup does not exist”. These errors usually occur when you have created a new database or changed the database recovery model from Simple to Full. The answer is to determine, before you run the backup, whether a differential or transaction log backup can be performed. You can use the DatabaseBackup procedure’s @ChangeBackupType option to change the backup type dynamically if a differential or transaction log backup cannot be performed.
Here’s an example of how to use the @ChangeBackupType option:
Back up to Multiple Files
Databases are becoming larger and larger. The SQLCAT team posted an article about how to tune the performance of SQL Server backup compression, by using multiple backup files, and the BUFFERCOUNT and MAXTRANSFERSIZE options. The DatabaseBackup procedure supports these recommendations:
Run Integrity Checks of Very Large Databases
The SQL Server Maintenance Solution has been designed to do integrity checks of very large databases. In the DatabaseIntegrityCheck procedure you can choose do the checks on the database level, the filegroup level, or the table level. It also supports limiting the checks to the physical structures of the database:
Question. Did any of those above items make you nod, smile or grimace in remembered pain? Then you've been in the DBA, officially or unofficially, seat. Best of all is the price on these scripts, free. Well even better, is reading the scripts and using them as a learning tool...