Using the LIKE keyword to create similar tables

  • Thread starter Thread starter Joel Whitehouse
  • Start date Start date
J

Joel Whitehouse

Hey Guys,

I want to create tables through ADO that have the exact same fields that
are in an existing table in my access 2003 .mdb file. I don't want to
copy any data from the old table to the new table, I just want to create
a new table with the same basic structure.

I tried using the following query to create a new table with the same
structure, but I get an error trying to run it:

"CREATE TABLE myNewTable LIKE myOldTable;"

When I run that query through ADO, I get them "Syntax error in CREATE
TABLE statement" trying to run it.

What other statement can I use to copy a table structure?

-Joel
 
Just copy and paste the table. When you paste it it will offer you three
radio buttons. One says "Structure Only".
 
Rick said:
Just copy and paste the table. When you paste it it will offer you three
radio buttons. One says "Structure Only".
Rick - thanks for the info. Does this mean that I cannot copy tehg
structure programmaticaly? I have a program that needs to do this many
times.

-Joel
 
Ah. That I do not know. Hopefully someone will jump in if they know.

Could you make a blank table and leave it out there as a template and then
always copy from it? Or do you need to to copy from different tables at
times?
 
Rick B wrote:

Could you make a blank table and leave it out there as a template and then
always copy from it? Or do you need to to copy from different tables at
times?

Oh yes - it is an empty template table that I designed in access. The
DB will be manipulated from VB through ADO, and it's just much more
reliable to copy rather than try to make VB do all the CREATE TABLE
footwork.

-Joel
 
Back
Top