Shrink Method
Esse recurso será removido em uma versão futura do Microsoft SQL Server. Evite usar esse recurso em desenvolvimentos novos e planeje modificar os aplicativos que atualmente o utilizam.
The Shrink method attempts to reduce the size of a referenced operating system file, or attempts to reduce the size of all operating system files maintaining the referenced Microsoft SQL Server database.
Sintaxe
object.Shrink(NewSize, Truncate)
Parts
object
Expression that evaluates to an object in the Applies To list.NewSize
Long integer that specifies a new target size as described in Settings.Truncate
Long integer that directs method behavior as described in Settings.
Prototype (C/C++)
HRESULT Shrink(long NewSize, SQLDMO_SHRINK_TYPE Truncate);
Comentários
For the Database object, the NewSize argument is set using any negative number or a number from 1 through 100. When negative, the Shrink method to attempts to shrink files maintaining the database to their smallest possible sizes. A positive value represents a percentage of the target reserved as unused space. For example, specify 5 to shrink a database leaving five percent free space for future growth.
For the DBFile and LogFile objects, the NewSize argument is set using any negative number, zero, or any positive integer. When negative, the Shrink method attempts to shrink the referenced file to its smallest possible size. Zero or a positive value represents a target file size as a number of megabytes.
Set the Truncate argument using these values.
SQLDMOShrink_Default
Data in pages located at the end of the file(s) is moved to pages earlier in the file(s). File(s) are truncated to reflect allocated space.SQLDMOShrink_EmptyFile
Migrate all data from the referenced file to other files in the same filegroup. (DBFile and LogFile object only)SQLDMOShrink_NoTruncate
Data in pages located at the end of the file(s) is moved to pages earlier in the file(s).SQLDMOShrink_TruncateOnly
Data distribution is not affected. File(s) are truncated to reflect allocated space, recovering free space at the end of any file.