Sunday, March 25, 2012

dbcc shrink database

Morning,
Is there a specific command/clause in the DBCC SHRINKDATABASE command where I can force a database to release free space to the operating system ?
Cheers,
DuncanMorning,

Is there a specific command/clause in the DBCC SHRINKDATABASE command where I can force a database to release free space to the operating system ?

Cheers,

Duncan

yes . use TRUNCATEONLY.
from BOL:

TRUNCATEONLY

Causes any unused space in the data files to be released to the operating system and shrinks the file to the last allocated extent, reducing the file size without moving any data. No attempt is made to relocate rows to unallocated pages. target_percent is ignored when TRUNCATEONLY is used.|||See BOL for it

DBCC SHRINKDATABASE ( database_name , TRUNCATEONLY )

TRUNCATEONLY will reduce all free space until last extension allocated.
Else, try

DBCC SHRINKDATABASE ( database_name , 1 )

to release all less 1 percent|||Thanks fellas but I've tried both of those options and the database in question has automatically grabbed any existing space as free space. Both commands completed after only a few seconds.

FYI - The database is set to autogrow but only in very small amounts. The database grabs far more free space.

Is it worth turning off autogrow or is it possible that the database has been corrupted in some way ?

Any ideas ?

No comments:

Post a Comment