Groups | Blog | Home
all groups > sql server (microsoft) > december 2005 >

sql server (microsoft) : Database size vs total table and index size



damezumari
12/29/2005 5:41:29 AM
I use SQL Server 2000.

My database is 1912.69 MB with no available free space.
My logfile is 1 MB.
The size of all tables and indexes add up to 200 MB.
I have no diagrams, two views, fifty stored procedures, six users, ten
roles, no rules, no defaults, no user defined data types, no user
defined functions.
Autoshrink is set to true.

My question:

How can the database be almost 2 GB when the tables and indexes add up
to only 200MB?

When I try to shrink manually in SQL Enterprise Manager I get no error
message, but no shrinking occurs.

I am grateful for any help.

Regards,

Jan Nordgreen
Phil
1/3/2006 4:15:29 AM
Try shrinking the database using DBCC SHRINKFILE in Query Analyzer (I
always find this more effective than using EM). Do the following:

use database <databasename>
go

select * from sysfiles
go

-- this will list the various logical devices, their current size (in
8k pages) and the fileid that
-- they've been assigned. Your primary datafile is usually fileid 1
-- Now shrink the physical datafile by running the command:

dbcc shrinkfile(1) -- or whatever other file number you wish to shrink
go

-- This can be repeated for each file in the database if necessary,
including logfiles.
-- (Best to backup or truncate a logfile before shrinking it).
Logfiles generally shrink very
-- quickly, datafiles can take some time.
AddThis Social Bookmark Button