473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQLSVR 2005 SP2 / Shrink data file will not work

Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2
compability mode 90, recovery model simple.

I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK

Shrink database (with reorganize and release unused pace) -no any affets,
data file size will be same still, 98% free space.
Log size 1 Mb.

Shrink datafile with log works fine, but not with datafile (No any errors
occured).

I tried without any helps:
- Database full backup->restore to different SQL Server -same problem in
other server.
- Change recovery model to full and back to simple.
- compability level 80 and 90.
I know that lastest "option" is that I should script the database and copy
data from old to new one,
but do you have any other ideas?`

Br, Major


Sep 22 '08 #1
6 8773
Major,

I don't know if this fits, of course, but have you run DBCC CLEANTABLE?

When you run DBCC SHRINKFILE ('Datafile', targetsize) I trust that you are
not using TRUNCATEONLY. (Because, a page of data could still exist out at
the 40GB part of the file.)

Something I have never personally done, but which is a possibility, is to
add another file to the filegroup, then run:
DBCC SHRINKFILE ('Datafile1',EMPTYFILE)
This will move all of the data to the other file(s) in the filegroup, after
which the first file can be dropped. (But, as I said, this is Books Online
information, not personal experience.)

RLF
"Major Drake" <ma*********@pp.inet.fi.HALOOOOOOO.fiwrote in message
news:%g*************@read4.inet.fi...
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2
compability mode 90, recovery model simple.

I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK

Shrink database (with reorganize and release unused pace) -no any
affets, data file size will be same still, 98% free space.
Log size 1 Mb.

Shrink datafile with log works fine, but not with datafile (No any errors
occured).

I tried without any helps:
- Database full backup->restore to different SQL Server -same problem in
other server.
- Change recovery model to full and back to simple.
- compability level 80 and 90.
I know that lastest "option" is that I should script the database and copy
data from old to new one,
but do you have any other ideas?`

Br, Major


Sep 22 '08 #2
Major Drake (ma*********@pp.inet.fi.HALOOOOOOO.fi) writes:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2
compability mode 90, recovery model simple.

I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK
And all tables have clustered indexes?
Shrink database (with reorganize and release unused pace) -no any
affets, data file size will be same still, 98% free space.
Try using DBCC SHRINKFILE instead. Books Online says about DBCC
SHRINKDATABASE:

The database cannot be made smaller than the minimum size of the
database. The minimum size is the size specified when the database is
originally created, or the last size explicitly set by using a file
size changing operation such as DBCC SHIRNKFILE or ALTER DATABASE.

But about DBCC SHRINKFILE:

You can shrink a file to a size that is less than the size specified when
it was created. This resets the minimum file size to the new value.

A tip is to specify a target size to DBCC SHRINKFILE. I have found that
it completes faster that way.

Don't forget to reindex your tables when you are done. Shrinking induces
a lot of fragmentation.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Sep 22 '08 #3
In addition to the other posts, please read:

http://www.karaszi.com/SQLServer/info_dont_shrink.asp

If you ran the size up to 40GB as a test, and are going to do so again, you
are much better off leaving it as is than shrinking it to the bare minimum
and then running the size up again.


On 9/22/08 6:17 AM, in article %g*************@read4.inet.fi, "Major Drake"
<ma*********@pp.inet.fi.HALOOOOOOO.fiwrote:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2
compability mode 90, recovery model simple.

I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK

Shrink database (with reorganize and release unused pace) -no any affets,
data file size will be same still, 98% free space.
Log size 1 Mb.

Shrink datafile with log works fine, but not with datafile (No any errors
occured).

I tried without any helps:
- Database full backup->restore to different SQL Server -same problem in
other server.
- Change recovery model to full and back to simple.
- compability level 80 and 90.
I know that lastest "option" is that I should script the database and copy
data from old to new one,
but do you have any other ideas?`

Br, Major

Sep 22 '08 #4
I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK

Shrink database (with reorganize and release unused pace) -no any
affets, data file size will be same still, 98% free space.
Log size 1 Mb.

Shrink datafile with log works fine, but not with datafile (No any errors
occured).

I tried without any helps:
- Database full backup->restore to different SQL Server -same problem in
other server.
- Change recovery model to full and back to simple.
- compability level 80 and 90.
I know that lastest "option" is that I should script the database and copy
data from old to new one,
but do you have any other ideas?`
This is now resolved:

I see that dbcc checktable shows that there were xx rows in xxxx pages,
but the table was empty (rows were deleted from table, count(*) was zero).

I should drop all foreign keys, truncate all empty tables and recreate
foreign keys.
After it shrink file will fork fine, now database size is 50 Mb ;-)...

Sep 30 '08 #5
Major Drake (ma*********@pp.inet.fi.HALOOOOOOO.fi) writes:
I see that dbcc checktable shows that there were xx rows in xxxx pages,
but the table was empty (rows were deleted from table, count(*) was zero).
Page and extent deallocation can be deferred for large deletes, so that they
are not deleted until later. Although I think I've seen situations where
it never came to the end of the road. Reindexing the table could have
helped and saved you from dropping the FKs.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Sep 30 '08 #6
hello Drake,

I wrote this post few moments ago, maybe it could help you.
---------------*---------------*---------------*---------------
*---------------*---------------*---------------*

You would need to use "dbcc shrinkfile" but once a time and using
small amount of size.

Example.

You have a database of 10 GB called database_10 and you know you can
shrink to 7 GB , run in the Query Analyzer this sentences.

Run once a time to see if it is working.

database_10
files:
database_10_Data
database_10_Log

DBCC SHRINKFILE('database_10_Data',9800) -- Only Shrink to 9800 MB
--Depends on time it takes you can shrink more space.
DBCC SHRINKFILE('database_10_Data',9500) -- Only Shrink to 9500 MB
DBCC SHRINKFILE('database_10_Data',9000) -- Only Shrink to 9000 MB

DBCC SHRINKFILE('database_10_Data',8800) -- Only Shrink to 8800 MB
DBCC SHRINKFILE('database_10_Data',8500) -- Only Shrink to 8500 MB
DBCC SHRINKFILE('database_10_Data',8000) -- Only Shrink to 8000 MB

DBCC SHRINKFILE('database_10_Data',7800) -- Only Shrink to 9800 MB
DBCC SHRINKFILE('database_10_Data',7500) -- Only Shrink to 9800 MB
DBCC SHRINKFILE('database_10_Data',7000) -- Only Shrink to 9800 MB
With this you can shrink the database.
Hope this work for you.

Antonio S.
DBA and Web Developer.
http://www.grupoKino.com

---------------*---------------*---------------*---------------
*---------------*---------------*---------------*
On Sep 22, 3:17*am, "Major Drake"
<major.dr...@pp.inet.fi.HALOOOOOOO.fiwrote:
Windows 2003 64 bit sp2 + SQL Server std 32 bit sp2
compability mode 90, recovery model simple.

I have about 40 Gb database where is about 98% free space (I deleted data
from tables).

dbcc checkdb -OK.
dbcc reindex all tables -OK

Shrink database (with reorganize and release unused pace) -no any affets,
data file size will be same still, 98% free space.
Log size 1 Mb.

Shrink datafile with log works fine, but not with datafile (No any errors
occured).

I tried without any helps:
- Database full backup->restore to different SQL Server -same problem in
other server.
- Change recovery model to full and back to simple.
- compability level 80 and 90.

I know that lastest "option" is that I should script the database and copy
data from old to new one,
but do you have any other ideas?`

Br, Major
Oct 15 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SP | last post by:
I've production sql server 7 sp3 on windows NT. I had a 8GB data file of which 5GB were used and 3GB were unused. I wanted to take back the unused 3GB. So I did the following with EM GUI: 1. I...
1
by: R Camarda | last post by:
Help, I have a database that has a data file of 2GB and a log file of 31GB. In enterprise manager, when I choose shrink it says there is 30GB of unused space. When I shrink the database, it does...
5
by: BashiraInTrouble | last post by:
Hi Friends, I have tried almost everything but I cant seem to shrink the transaction log. Executing DBCC SQLPERF(LOGSPACE) gives me this info: Database Log Size (MB) Log Space Used (%) ...
4
by: Tommy.Vincent | last post by:
hi all, This will be a easy question for all out here. I have a database of 28GB. having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively. and a Transaction Log file of 156 mb. When i...
6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
5
by: Mark | last post by:
I'd like to automate the process of shrinking .jpg files using C#. I'd like to point at 1000 files, shrink them to 30%, and then resave the new files. I've seen the Graphics.DrawImage method, but...
0
by: dmlinliverpool | last post by:
I am running VS.net 2005 Express and Sql Server 2005 Express. The DB and VS are both on the same PC. I cannot connect to a database from within VS. In Database Explorer I click Connect To...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.