?
Solved

Automatically compact and repair nightly

Posted on 2004-09-30
7
Medium Priority
?
611 Views
Last Modified: 2010-08-05
I'm running WinXP with Access 2003 front end / back end databases.  I would like to automatically compact and repair the back end databases on a regular basis.  My question is:

1.  How frequently should I be running the compact and repair?
2.  What is the most efficient way to accomplish this?  

I've read questions about using an automated task, and I've also read that I should make a back-up copy before doing the compact and repair.  Is that really necessary?  If so, then I guess I would need to do a backup first, and then compact and repair.  

What's the best approach for this?  Thanks.
0
Comment
Question by:DanielAttard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12194065
daniel,
check here

How to Compact Databases At a Scheduled Time
http://support.microsoft.com/?kbid=209979
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 12194087
or you could do it using the task scheduler
Control Panel>Scheduled Task

you need a .bat file to do this
0
 
LVL 34

Expert Comment

by:flavo
ID: 12194392
c:\pathToAccess\access.exe c:\myDb.mdb /compact  inthe shedualer (as cap said)
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 27

Assisted Solution

by:jjafferr
jjafferr earned 800 total points
ID: 12194780
Hi guys

What compact and repair does is,
it makes a copy of your database as db1.mdb in the same directory as your existing mdb,
then it compacts it,
Then deletes the original mdb,
then renames the db1.mdb to your original mdb name.
so you have to make sure there is enough space on your harddisk during this process,

So during this process if something went wrong,
then you will not have the original working mdb,
but rather the new corrupt mdb (it never happend to me so far, touch wood).

How frequently?
I guess it depends on how your mdb is structured,
for example, if you use temp tables and delete them,
then Access will not release this empty space, unless you compact and repair,
so in this case, you will have to watch, after how many usages the mdb grows big,
so you make your code in such a way that will count how many times the mdb was used/open,
OR check its size compared to a size on a particular date, then do the compact and repair automatically with code.

But if your mdb was only updating records and adding records, then your compact and repair shold be with longer time interval.

Both capricorn1 and flavo have given you the way to compact and repair,
but if you are interested in a code that would check the size of the mdb then do comapct and repair, then check here:
http://www.experts-exchange.com/Databases/MS_Access/Q_20291042.html


jaffer
0
 
LVL 3

Expert Comment

by:Moother
ID: 12194931
You can use this handy compacting app. Also does backups!

http://www.peterssoftware.com/cal.htm

M
0
 

Author Comment

by:DanielAttard
ID: 12196873
Thanks for the ideas everyone.  I like the idea of simply adding a scheduled task to accomplish the compact and repair operation since I already have a couple of scheduled tasks that I need to monitor from time to time, so adding another one seems like a logical solution to this issue.  One remaining question though.  

If I'm not particularly concerned about database bloat (because I don't use temporary tables), what other reason would there be for me to do a regularly scheduled compact and repair?  Should this process be done on a regular basis just for the heck of it, say on a monthly or weekly basis, or should I just leave the damn thing along since the size is not growing.  I'm just concerned with the possibility of corruption making its way into the database somehow, and I want to try and catch it at the earliest possible opportunity.

I'm worried that perhaps I could be doing "too much" to protect my data.  

p.s.  I also checked out that utility from Peterssoftware.com, and it worked like a charm.  Seems like an easy way to compact and create backups.  

0
 
LVL 3

Accepted Solution

by:
Moother earned 1200 total points
ID: 12197571
You're quite right to add it to your nightly shedule (using the cal app above is easy as you now know.) because it might help save potential problems.

Not only will compacting your DB regularly protect it against corruption but making regular backups can help you trace unexplained data irregularities. My colleagues know not to screw with my data because I can always catch them out!

I run a small app which gathers around 20meg in the back end per year and it occasionally became inaccessible due to corruption but now that it gets compacted (2x per week) it doesn't show any signs of collapse. I also don't use temp tables but the thing can swell to double its size if left unattended.

Good Luck,

M
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question