DBCC SHRINKFILE in Microsoft SQL Server

DBCC SHRINKFILE

Shrinks the size of the specified data file or log file for the related database.

Syntax

DBCC SHRINKFILE     ( { file_name | file_id }         { [ , target_size ]
| [ , { EMPTYFILE | NOTRUNCATE | TRUNCATEONLY } ]
}   )

Remarks
DBCC SHRINKFILE applies to the files in the current database. Switch context to the database to issue a DBCC SHRINKFILE statement referencing a file in that particular database. For more information about changing the current database, see USE.
The database cannot be made smaller than the size of the model database.
Use DBCC SHRINKFILE to reduce the size of a file to smaller than its originally created size. The minimum file size for the file is then reset to the newly specified size.

Examples
This example shrinks the size of a file named Data file in the UserDB user database to 7 MB.

USE UserDB
GO
DBCC SHRINKFILE (Data File, 7)
GO

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.