Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Compact an Access Database from DTS


Compact an Access Database from DTS

Author
Message
Peter Williams
Peter Williams
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 1

Does anyone have any ideas on how to Compact & repair an Access datbase within a DTS package??

I basically have a 'delete from table' statement. I then export data from SQL Server into an Access database each night which contains updated results. The Access database is growing beyond believe. On last look, the mdb file was 300Mb. I compacted and repaired this database from within Access itself and the file reduced to 13mb!!

I have seen a couple of articles which point towards using this executable (http://support.microsoft.com/default.aspx?scid=kb;en-us;273956) however if possible I would prefer to use an ActiveX script at the end of processing, just to tidy things up and to avoid firing up server side applications in the background.

Any help would be much much much appreciated!

Thanks

Pete


AJ Ahrens
AJ Ahrens
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1760 Visits: 9

1. I would ensure that EVERY UPDATE, INSERT, DELETE query inside the Access database has "Use Transaction" property = FALSE/NO. This will DRAMATICALLY INCREASE the size of your DB if TRUE/YES.

As far as doing this via DTS I would NOT recommend it. You don't know if someone has left the application open in which case you will NOT be able to and could possibly corrupt it.

Instead, how about adding a button or an ON database CLOSE event to COMPACT/REPAIR ?





Good Hunting!

AJ Ahrens


webmaster@kritter.net
Henrik Staun Poulsen-237657
Henrik Staun Poulsen-237657
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 16

Pete,

I've tried getting DTS to delete records from an Access database to no avail. I ended up running a "copy" command to get an new empty copy of my Access database. BTW: The copy does not really support long filenames.

HIH

Henrik Staun Poulsen

Stovi Software


Peter Williams
Peter Williams
SSC Journeyman
SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)SSC Journeyman (95 reputation)

Group: General Forum Members
Points: 95 Visits: 1

Thanks for your replies. I think we're going to try a different approach rather than DTS.

Just to make my question a little clearer, I'll explain the scenario.

We have a SQL Server database which stores online internet activity for a range of clients. This database is currently 24 GB. We export individual client data to seperate Access databases (so in effect, each client has its own access database containing it's own activity for the current week).

At the end of the week, we empty the access database and export the current week's online data. So to summarise, our SQL Server is the datawarehouse, the Access database just gets updated with the last 7 days worth of activity.

Even though we delete data from the Access database and put new data in there, the file size continues to grow. Therefore, we need to compact the access files once they've been updated.

From what I gather, DTS isn't the best approach for this final step, so we're going to write a VB app and schedule it to run at certain intervals.

Thanks for everyones feed back.


Henrik Staun Poulsen-237657
Henrik Staun Poulsen-237657
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 16

Pete,

We're doing pretty much the same job as you are, and DTS runs just fine. If your only problem is that you cannot clear down the Access db, then it is easy to fix this, with my sugestion; as in

copy myEmptyDB.MDB ClientA2005_07_21.mdb

Best regards,

Henrik


Habib Zmerli
Habib Zmerli
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 3

Use the "Execute Process Task" with the following command :

"c:\Program Files\Microsoft Office\Office11\msaccess.exe /compact /repair"

PS. Parameters can be localted in the parameters field.

HABIB.




Kindest Regards,

Habib Zmerli (MVP)

Ian Paskin
Ian Paskin
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 3

Pete,

I compact an access db from a VB program each night so you may be able to use this to create an activeX DTS package

*******************************************

Dim jetDBEngine As DBEngine
Dim daoDB As DAO.Database
Dim fsoFS As Scripting.FileSystemObject
Dim strdb as string

strdb = "C:\mydb.mdb"

Set jetDBEngine = New DAO.DBEngine

'Compact Database into _Compacted file.
Set fsoFS = New Scripting.FileSystemObject
jetDBEngine.CompactDatabase strdb, strdb & "_Compacted"

'Then copy _Compacted file back on top of live file
fsoFS.CopyFile strdb & "_Compacted", strdb
fsoFS.DeleteFile strdb & "_Compacted"

'Establish Connection to Database
Set daoDB = jetDBEngine.OpenDatabase(strdb)

*********************************************

Ian


SQL Terminator
SQL Terminator
Old Hand
Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)Old Hand (323 reputation)

Group: General Forum Members
Points: 323 Visits: 645
In Process Tab of Execute Process Task Editor:

Executable:
C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE

Arguments:
/compact/repair "S:\Filename.mdb"
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search