472,786 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,786 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 8733
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.