Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there a truncate table command in Access?

Status
Not open for further replies.

Glowworm27

Programmer
May 30, 2003
587
US
I am doing a bulk insert into a database from another database, and want to truncate the table before I do the insert.

I have tryed the Delete * from table, but becasue it is an access database it grows in size everytime I do the bulk insert.

If not I would like to do a compact and repair, but the only way to do that is to have a different destination database, but I just want to compact the existing database not create a different one.

Any thoughts?

thanks
[cannon]

George Oakes
Goakes@TiresPlus.com = Programmer
George@1-Specialday.com = Mobile DJ
Check out this awsome .Net Resource!
 
Delete * ..." does what you want but Access is incapable of recovering the space allocated to the table when you clear all it's records. The only way to do that is to Compact the database ... which has it's own problems as you have noted.

You can handle the compact from within code using something like
[blue][tt]
DAO.DBEngine.CompactDatabase Path & DataBaseName, Path & SaveName
If Err.Number = 0 Then
[/tt][/blue][Green][tt]' Rename it after compacting[/tt][/Green][blue][tt]
Kill Path & DataBaseName
Name Path & SaveName As Path & DataBaseName
End If
[/tt][/blue]
Where "SaveName" is some temporary name for the Database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top