locked
how to clone an access table RRS feed

  • Question

  • User253847291 posted

    hello,


    im not sure if this question qualify for getting started topic however here is what im trying to do:

    ive an access database with a table (no data) i wish to duplicate the table lets say tabOrigin with a different name; as since the table is empty i just want to duplicate the structure; fields name, size, type etc..

    thank you,


    Thursday, July 22, 2010 7:36 AM

Answers

All replies

  • User370212504 posted

    For example:

    ALTER TABLE 
    base-table-name ADD CLONE 
    clone-table-name
    
    Thursday, July 22, 2010 8:25 AM
  • User-1199946673 posted

    SELECT * INTO tabNew FROM tabOrigin WHERE 1 = 0

    You could also download Database Administrator for MS Access. This is a classic ASP application that allows you to manage your online Access databases. You could also retrieve the SQL statement to recreate an existing table, and then execute that statement 

    Thursday, July 22, 2010 8:55 AM
  • User253847291 posted

    hello,

    ive found this solution:

    OleDbCommand cm = new OleDbCommand("SELECT tabTemp.* INTO " + tempTable + " FROM tabTemp", cnn);

    for some reason i didnt have to use WHERE specification (probably because of no records)


    is it possible to compact/restore the database from C# or is it just an access feature?


    thank you,


    Thursday, July 22, 2010 8:54 PM
  • User-1199946673 posted

    i didnt have to use WHERE specification (probably because of no records)
     

    Correct!

    is it possible to compact/restore the database from C#

    Yes:

    http://forums.asp.net/p/889415/3477047.aspx#940697

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 23, 2010 2:39 AM
  • User253847291 posted

    thank you, that did it!

    Friday, July 23, 2010 6:05 PM