When I need do maintenance task on a SQL Server DataBade, usually run the next steps:
use dbname; GO --Full backup of DB BACKUP DATABASE dbname TO DISK = 'Z:\SQLServerBackups\dbname.bak' ; GO -- Reclaim free space of the data base DBCC SHRINKDATABASE ; GO -- verify and repair tables and indexes DBCC CHECKDB REPAIR_REBUILD; GO -- update statistics on the database EXEC sp_updatestats; GO
References:
- https://technet.microsoft.com/en-us/library/ms176064(v=sql.105).aspx
- https://technet.microsoft.com/en-us/library/ms140255(v=sql.105).aspx
- https://technet.microsoft.com/en-us/library/ms186865(v=sql.105).aspx