Cannot shrink data file

Cannot shrink data file

Post by Joseph Albahar » Tue, 13 Mar 2001 08:03:08



I've got a data file which is 40GB, but is half empty.  I want to shrink it,
but the shrink doesn't work:

dbcc shrinkfile (file)

does nothing.  It just says DBCC execution completed immediately.  It
normally works fine for me.  I've run it hundreds of times before.

sp_spaceused reports that the file is only 20GB big and not 40GB!  I've run
dbcc updateusage, but to no avail.  And this is a data file, not a log file.
I'm currently running dbcc checkdb on the database, but am reluctant to use
it to fix any errors (assuming it finds any), because I don't want to take
the database offline or single-user.  It's OLTP and about 200GB.

Can anyone help with this?

TIA,

Joseph.

 
 
 

Cannot shrink data file

Post by Michael Brickle » Tue, 13 Mar 2001 09:33:33


I'm assuming your on SQL 7.
dbcc shrinkfile (db,%free)
The %free is the amount you want to be available after shrinking the
database.  BOL has this on dbcc shrinkfile.

Data moved to remaining space.   Space calculated to db size + the %free.


Quote:> I've got a data file which is 40GB, but is half empty.  I want to shrink
it,
> but the shrink doesn't work:

> dbcc shrinkfile (file)

> does nothing.  It just says DBCC execution completed immediately.  It
> normally works fine for me.  I've run it hundreds of times before.

> sp_spaceused reports that the file is only 20GB big and not 40GB!  I've
run
> dbcc updateusage, but to no avail.  And this is a data file, not a log
file.
> I'm currently running dbcc checkdb on the database, but am reluctant to
use
> it to fix any errors (assuming it finds any), because I don't want to take
> the database offline or single-user.  It's OLTP and about 200GB.

> Can anyone help with this?

> TIA,

> Joseph.


 
 
 

Cannot shrink data file

Post by Michael Brickle » Tue, 13 Mar 2001 09:42:38


Opps should be dbcc shrinkdatabase !

> I'm assuming your on SQL 7.
> dbcc shrinkfile (db,%free)
> The %free is the amount you want to be available after shrinking the
> database.  BOL has this on dbcc shrinkfile.

> Data moved to remaining space.   Space calculated to db size + the %free.



> > I've got a data file which is 40GB, but is half empty.  I want to shrink
> it,
> > but the shrink doesn't work:

> > dbcc shrinkfile (file)

> > does nothing.  It just says DBCC execution completed immediately.  It
> > normally works fine for me.  I've run it hundreds of times before.

> > sp_spaceused reports that the file is only 20GB big and not 40GB!  I've
> run
> > dbcc updateusage, but to no avail.  And this is a data file, not a log
> file.
> > I'm currently running dbcc checkdb on the database, but am reluctant to
> use
> > it to fix any errors (assuming it finds any), because I don't want to
take
> > the database offline or single-user.  It's OLTP and about 200GB.

> > Can anyone help with this?

> > TIA,

> > Joseph.

 
 
 

Cannot shrink data file

Post by Tibor Karasz » Tue, 13 Mar 2001 18:04:12


FYI (don't know if it applies here): you cannot shrink the file to smaller size than
the initial size.

--
Tibor Karaszi, SQL Server MVP
FAQ from Neil at: http://www.sqlserverfaq.com
Please reply to the newsgroup only, not by email.


Quote:> I've got a data file which is 40GB, but is half empty.  I want to shrink it,
> but the shrink doesn't work:

> dbcc shrinkfile (file)

> does nothing.  It just says DBCC execution completed immediately.  It
> normally works fine for me.  I've run it hundreds of times before.

> sp_spaceused reports that the file is only 20GB big and not 40GB!  I've run
> dbcc updateusage, but to no avail.  And this is a data file, not a log file.
> I'm currently running dbcc checkdb on the database, but am reluctant to use
> it to fix any errors (assuming it finds any), because I don't want to take
> the database offline or single-user.  It's OLTP and about 200GB.

> Can anyone help with this?

> TIA,

> Joseph.

 
 
 

Cannot shrink data file

Post by Joseph Albahar » Tue, 13 Mar 2001 18:32:21


Thanks for your replies.  I am on SQL 7.0.

(1) I do not want to shrink the whole database, just one file.  The whole database is >200GB and it's only one file that needs shrinking.  dbcc shrinkfile is the correct command.  I've done this dozens of times and it's always worked before.

(2) The file was originally created with a size of only 5GB, so it should shrink to 20GB.

(3) I am not specifying a target size because I want to shrink it as far as it'll go.

Any more ideas would be much appreciated.

Thanks,

Joseph

Quote:> I've got a data file which is 40GB, but is half empty. I want to shrink
it,
> but the shrink doesn't work:

> dbcc shrinkfile (file)

> does nothing. It just says DBCC execution completed immediately. It
> normally works fine for me. I've run it hundreds of times before.

> sp_spaceused reports that the file is only 20GB big and not 40GB! I've
run
> dbcc updateusage, but to no avail. And this is a data file, not a log
file.
> I'm currently running dbcc checkdb on the database, but am reluctant to
use
> it to fix any errors (assuming it finds any), because I don't want to take
> the database offline or single-user. It's OLTP and about 200GB.

> Can anyone help with this?

> TIA,

> Joseph.

*** Sent via Developersdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
 
 

1. cannot shrink log file

Im trying to free up some log space by first doing a log backup the dbcc
shrinkdatabase. I get the message

Cannot shrink log file 2 (chris_084_Log) because all logical log files are
in use.
DbId   FileId CurrentSize MinimumSize UsedPages   EstimatedPages
------ ------ ----------- ----------- ----------- --------------
78     2      545744      128         545744      128

(1 row(s) affected)

DBCC execution completed. If DBCC printed error messages, contact your
system administrator.

I had this happen the other day to and I thought I had it figured out but I
guess not. I need to be able to code this, not just do in Enterprise Manager
please.
Thanks in advance.

2. MSDN COPY... SQL

3. Cannot shrink log file of model database

4. How do I view all stored procedure code at once?

5. Cannot truncate log or shrink file

6. Critical updating problem

7. Cannot shrink log file

8. unwanted click event after refresh datacontrol

9. Shrinking data file and log file

10. Database file shrink if auto-shrink off

11. cannot identify data file 1 - file not found

12. shrinking file size by deleteing data in image fields

13. how to shrink data file