One, Check Database Integrity Task
Check the allocation and structural integrity of the user and system tables, and indexes in the database, by running the D BCC CHECKDB Transact-SQL statement. Running DBCC ensures that any integrity problems with the database is reported, thereby allowing them to be addressed Later by a system administrator or database owner.
Include indexes
Check the integrity of the index pages as well as the table data pages.
View TSQL Code
-- include Inedexes DBCC CHECKDB (N'db_study') with no_infomsgs--not Included indexDBCC CHECKDB (N'db_study', NOINDEX)
Two, Shrink Database Task
use the shrink Database Task dialog to create a task that attempts T o Reduce the size of the selected databases. Use the options below to determine the amount of unused space to remain in the database after the database is shrunk (the Larger the percentage, the less the database can shrink). The value is based on the percentage of the actual data in the database. For example, a 100-MB database containing MB of data and + MB of free space, with a free space percentage of Percen T, would result in (MB) of data and a of free space (because-percent of up to MB). Only excess space on the database is eliminated. Valid values is from 0 through.
Shrinking data files recovers space by moving pages of data from the end of the file to unoccupied space closer to the fro NT of the file. When enough free space was created at the end of the file, data pages at end of the the file can deallocated and returned to th E file system.
Caution:data that's moved to shrink a file can be scattered to any available location in the file. This causes index fragmentation and can slow the performance of queries, that search a range of the index. To eliminate the fragmentation, consider rebuilding the indexes on the file after shrinking.
View TSQL Code
-- Retain freed space in database files DBCC Shrinkdatabase (N'db_study', truncateonly)--Return Freed space to OSDBCC shrinkdatabase (N'db_study'), Notruncate)
Maintenance Plan Usage4:check Integrity and Shrink database