Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using dbcc shrinkdatabase

Status
Not open for further replies.

rhofing

MIS
Dec 12, 2001
25
0
0
CA
At the risk of sounding like a mathematical moron I have a question about DBCC SHRINKDATABASE. How is the actual free space calculated based on the percentage free value specified in the command?

I take an example from BOL:
mydb data file contains 6 MB of data, if you specify a target_percent of 25 for shrinking mydb. SQL Server calculates the target size for this file to be 8 MB (6 MB of data plus 2 MB of free space).

I understand that 2MB is 25% of 8MB. But how did they arrive at the 8MB value in the first place? Another way to ask this question is: 6MB plus how many MB's would represent 25% of the resulting value?

I ask this question because I am taking the 70-228 practice tests and there are a number of similar questions.

I am pulling out what little hair I have left :)

Thank you.

Ric
 
DBCC SHRINKDATABASE will shrink the database now grow it.

if your mdb file is 10mb and 8mb of the space actually contains data and you shrink it 25% it will shrink 25% of the actual free space in this case .5mb.

You use the ALTER DATABASE command to grow the database.

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
MDXer,

Rhofing has it right. Let's say your database is 10mb total. 6mb of that is data. If you DBCC SHRINKDATABASE using 25%, it won't shrink it 25%. It will shrink the free space 75% (the 25% is how much free space you want left after the database is shrunk).

-SQLBill
 
SQLBILL,
You are right I did get thet percentage backwards.

The way in which Rhofing described the issue it appeared to me that the file was 6 megs and the result was to be 8 megs which isn't shrinking.

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
He left out the part about how big the database file was in total size and only mentioned how much DATA there was (6mb of data). So without all the information, as you said it does look like it's growing.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top