Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Shrink DB Expand / Collapse
Author
Message
Posted Wednesday, July 30, 2008 7:34 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, September 29, 2014 12:03 PM
Points: 434, Visits: 355
I have 300 GB user database I can see around 150 free space on data file.

When I tried to shrink database my MDF file still shows me 300 GB how to shrink this.

I ran DBCC command and shrink Database but no impact.
Post #543466
Posted Wednesday, July 30, 2008 7:44 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 6:15 AM
Points: 485, Visits: 11,021
Hi,
Try to shrink file instead of database, this would make the file shrink.
If this does not help, then you must see what the initial size of database(datafile) is set to.
Post #543478
Posted Wednesday, July 30, 2008 8:05 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, September 29, 2014 12:03 PM
Points: 434, Visits: 355
I did that when I do shrink file I am getting this error below:

A server error occured on the current command. The results, if any, should be discarded File ID 1 of database ID 7 canot be shrunk as it is either being shrunk by another process or is empty
Post #543509
Posted Wednesday, July 30, 2008 9:45 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 6:15 AM
Points: 485, Visits: 11,021
Hi,

Ok This means that your original job to shrink is still running in the background.

Do a sp_who2 and a sp_lock to see which process is holding that database. then once you have that then you can do a dbcc inputbuffer (spid) to check the command that is running.

You are going to have to wait for it to stop, don't restart sql server as you will get a corruption on the databases.

Hope this helps
Post #543646
Posted Wednesday, July 30, 2008 12:28 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, September 29, 2014 12:03 PM
Points: 434, Visits: 355
Nope nothing is been running, I checked earlier and I didnow as well.
Post #543801
Posted Wednesday, July 30, 2008 1:14 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, October 14, 2014 6:15 AM
Points: 485, Visits: 11,021
Hi

What is the error code it gives you with the last error??

Post #543852
Posted Wednesday, July 30, 2008 2:24 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 12:34 PM
Points: 31,204, Visits: 15,649
Are you trying to shrink this down to 150MB? You want to keep free space in the file in general.

The shrinking can be slow or fast, depending on the load your DB experiences and the locks that might be held on files. It can take some time.

Can you restart the instance and then try shrinking if you really need to?







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #543904
Posted Wednesday, July 30, 2008 3:26 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, May 22, 2014 7:04 AM
Points: 1,688, Visits: 8,766
Nita,

Please make sure AUTOSHRINK option is turned OFF for the database in question.

Also, try shrinking database file in chunks rather than specifying a big size in one shot. Use dbcc shrinkfile(fileid,DesiredSize)

Size--Specify the desired size which is 150,200 MB or 1 GB(it is based on the server I/O subsystem) less than the current size.

For 300 GB database specify dbcc shrinkfile(1,299000) first if it works fine and completes in less than 10 minutes than go ahead with reducing the shrink size during later executions.

Perform this activity when database is used at minimum.

Manu
Post #543931
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse