Dela via


Shrink Database Task

The Shrink Database task reduces the size of SQL Server database data and log files. For more information, see Shrinking a Database.

By using the Shrink Database task, a package can shrink files for a single database or multiple databases. Shrinking data files recovers space by moving pages of data from the end of the file to unoccupied space closer to the front of the file. When enough free space is created at the end of the file, data pages at end of the file can deallocated and returned to the file system.

Warning

Data that is 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.

The Shrink Database task encapsulates a DBCC SHRINKDATABASE command, including the following arguments and options:

  • database_name

  • target_percent

  • NOTRUNCATE or TRUNCATEONLY.

If the Shrink Database task shrinks multiple databases, the task runs multiple SHRINKDATABASE commands, one for each database. All instances of the SHRINKDATABASE command use the same argument values, except for the database_name argument. For more information, see DBCC SHRINKDATABASE (Transact-SQL).

Configuring the Shrink Database Task

You can set properties through the SSIS Designer. This task is in the Maintenance Plan Tasks section of the Toolbox in SSIS Designer.

For more information about the properties that you can set in the SSIS Designer, click the following topic:

For more information about setting these properties in the SSIS Designer, click the following topic:

Integration Services icon (small) Stay Up to Date with Integration Services

For the latest downloads, articles, samples, and videos from Microsoft, as well as selected solutions from the community, visit the Integration Services page on MSDN or TechNet:

For automatic notification of these updates, subscribe to the RSS feeds available on the page.