Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Compacting SQL DB
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Compacting SQL DB

 Post Reply Post Reply
Author
rob_andy View Drop Down
Newbie
Newbie


Joined: 21 February 2003
Location: United Kingdom
Status: Offline
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote rob_andy Quote  Post ReplyReply Direct Link To This Post Topic: Compacting SQL DB
    Posted: 21 March 2005 at 4:50pm
I'm new to MS SQL, I've had to upgrade from Acess to SQL because of the rate of expansion of my car club.  I've had a really steep learning curve and now know a fair bit about importing and copying etc...  After a lot of trouble shooting I have managed to move my access across into an SQL environment.  The SQL package I'm using is only web based and does not use enterprise manager.  Does anybody out there know how to stream line my db, at the moment in access it shows as 15mb, when I import and do all the moving about it shows as 35+ MB with a log file of over 50 MB.  My limit for both is 200 so I want to get this down as much as possible.  Any ideas?  Thanks for help in advance.
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 5:40pm
If you don't need anything in your log you can run
 
backup log yourdbname with truncate_only
dbcc shrinkdatabase (yourdbname)
 
which should compact your db a bit and "empty" the log file.
Back to Top
rob_andy View Drop Down
Newbie
Newbie


Joined: 21 February 2003
Location: United Kingdom
Status: Offline
Points: 33
Post Options Post Options   Thanks (0) Thanks(0)   Quote rob_andy Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 6:30pm
Wow, thanks so much for that.  Tried it and worked a treat.  Going to move across tomorrow onto the SQL.  Owe you one.  R
Back to Top
sifra View Drop Down
Newbie
Newbie
Avatar

Joined: 20 March 2005
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote sifra Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2005 at 12:25pm
DBCC SHRINKFILE works a treat for a few months.  If autogrow is on then high frequency shrinking and expanding of the database files will cause extensive OS fragmentation, so your DBCC DBREINDEX will be of little value trying to eliminate extent level fragmentation.
 
It is better to set your filegroups to a size that allows 6-12 months of growth, and set autogrow off.  Fixed size filegroups never fragment at the OS level.  SQL server will perform block reads of data pages only if they are logically and physically contiguous.
 
The risk is that fixed size filegroups will fill up, so set an alert that emails you when your filegroup is > 90% full. Wink
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.