Can't Shrink Data File

Can't Shrink Data File

Post by Jonathan Dav » Thu, 16 Sep 1999 04:00:00



Here's my problem:

I have a database (web_db1) which consists of two data files (and of
course a transaction log file which is not the focus here):

web_db1_Data.mdf
web_db1_Data2_Data.mdf

The first file web_db1_Data.mdf is HIGHLY fragmented. I let it
auto-grow from 1MB over a long period of time on a disk which gets a
lot of usage from other processes. The file is now 6.5GB in size and
the data only consumes 1.7 GB of it. When I try to run:

USE web_db1

GO

DBCC SHRINKFILE (web_db1_Data)

I get:

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

Then I look at the size of the file in explorer and the file size is
the same, 6.5GB.

I've also tried running:

DBCC SHRINKFILE (web_db1_Data, 2000)
Same...
DBCC SHRINKFILE (web_db1_Data, 2000, TRUNCATEONLY)
Same...

DBCC SHRINKFILE (web_db1_Data, 0, EMPTYFILE)
This command moved all the user data over to the other data file, but
it did not shrink the file.

I cannot shrink this file! All I want to do is defrag it by shrinking
the file in SQL, stopping SQL service, copy the small file out to a
net resource, copy it back in, start SQL Service, pre-allocate a full
6GB, and have a contiguious 6G data file.

What I gathered from reading, was that the first data file defined is
the primary FILE (I'm not using any other filegroup besides PRIMARY),
which contains all the system tables (i.e.:sysobjects) which cannot be
dropped with ALTER DATABASE REMOVE FILE *Correct me if I'm wrong*. Why
won't DBCC SHRINKFILE(DataFile1, 0 , EMPTYFILE) work on primary files?

Any help would be greatly appreciated!
-Joanthan Davis

 
 
 

Can't Shrink Data File

Post by Jerry Spive » Thu, 16 Sep 1999 04:00:00


Johathan - You have two .mdf files, which one is your primary file?

--
HTH
--
Jerry Spivey
MCT, MCSE, MCSD
Senior SQL Instructor - Consultant
ARIS Corporation  Bellevue, WA
(Please reply to the newsgroup only, not by email.)


Quote:> Here's my problem:

> I have a database (web_db1) which consists of two data files (and of
> course a transaction log file which is not the focus here):

> web_db1_Data.mdf
> web_db1_Data2_Data.mdf

> The first file web_db1_Data.mdf is HIGHLY fragmented. I let it
> auto-grow from 1MB over a long period of time on a disk which gets a
> lot of usage from other processes. The file is now 6.5GB in size and
> the data only consumes 1.7 GB of it. When I try to run:

> USE web_db1

> GO

> DBCC SHRINKFILE (web_db1_Data)

> I get:

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

> Then I look at the size of the file in explorer and the file size is
> the same, 6.5GB.

> I've also tried running:

> DBCC SHRINKFILE (web_db1_Data, 2000)
> Same...
> DBCC SHRINKFILE (web_db1_Data, 2000, TRUNCATEONLY)
> Same...

> DBCC SHRINKFILE (web_db1_Data, 0, EMPTYFILE)
> This command moved all the user data over to the other data file, but
> it did not shrink the file.

> I cannot shrink this file! All I want to do is defrag it by shrinking
> the file in SQL, stopping SQL service, copy the small file out to a
> net resource, copy it back in, start SQL Service, pre-allocate a full
> 6GB, and have a contiguious 6G data file.

> What I gathered from reading, was that the first data file defined is
> the primary FILE (I'm not using any other filegroup besides PRIMARY),
> which contains all the system tables (i.e.:sysobjects) which cannot be
> dropped with ALTER DATABASE REMOVE FILE *Correct me if I'm wrong*. Why
> won't DBCC SHRINKFILE(DataFile1, 0 , EMPTYFILE) work on primary files?

> Any help would be greatly appreciated!
> -Joanthan Davis


 
 
 

Can't Shrink Data File

Post by Jonathan Dav » Fri, 17 Sep 1999 04:00:00


The file which I can't shrink.

web_db1_Data.mdf

On Wed, 15 Sep 1999 17:09:11 -0700, "Jerry Spivey"


>Johathan - You have two .mdf files, which one is your primary file?

>--
>HTH

 
 
 

1. Shrinking data file and log file

This past weekend I purged a lot of data in one of my
databases.  I've noticed that my data and log files
instead of shrinking actually grew a little.  I went into
Enterprise Manager and chose my database, selected Shrink
database and chose my log file to shrink.  I specified an
amount for it to be shrunk to and clicked ok...it said
that the file was shrunk successfully but whenever I
select properties on the database and choose the
transaction log my space allocated is still the same.  Am
I missing something?

Leon

2. GRAPHICAL DBA TOOLS - any suggestions??

3. Shrink tables doesn't shrink enough

4. Is triggers really necessary ?

5. Shrink table doesn't shrink enough

6. Admin ID - how to change

7. if you will promise Allahdad's swamp against cans, it will angrily depart the unit

8. How to star sqlldr from cmd line or PL/SQL program?

9. Cans access2.0 engine access btrieve files?

10. log file size - can't shrink

11. Database File Won't Shrink

12. Database file shrink if auto-shrink off

13. can't shrink log file