Solved

Compacting MS SQL Server 2000 database

Posted on 2004-09-21
5
191 Views
Last Modified: 2013-12-25
Hi experts,
How to compact a MS SQL Server 2000 database from within VB6 using SQLDMO?
Thanks in advance,
Ganaa
0
Comment
Question by:Ganaa
  • 2
5 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
There is no such thing. It is not like Access. SQL re-use its lost space itself.
0
 
LVL 7

Accepted Solution

by:
kmorris1186 earned 50 total points
Comment Utility
This is the closest you going to get to the "compact" feater of Access..

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_dbcc_3pd1.asp

also preforms the same function as "Shrink" from Enterprise Manager.
0
 

Expert Comment

by:XgenX
Comment Utility
The proper way to do this is to set up a database maintenance plan in the SQL Enterprise Manager. This is where you will set up a backup plan for the database. I find that it works best if you set up a database backup and a log file backup seperately. Depending on the strain on your database you could do something like backup the full database twice a day, and backup the log file every 20 minutes. In the database properties set the autoshrink property to true. The database files will be trimmed when the database is backed up but the log files are trimmed when the log is backed up. This is why you may see an enourmous log file and you may have to go into query analyzer and type 'backup log <databasename> with truncate_only'. There are other settings in the backup that will redo the indexes and allow you to set the freespace size to something like 20% or so so that it won't have to resize the database as soon as someone writes to it.
0
 

Expert Comment

by:XgenX
Comment Utility
By the way, if you want, you may be able to set up that maintenance plan in SQLDMO.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now