A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

create table scripts



 
 
Thread Tools Display Modes
  #1  
Old January 23rd, 2006, 02:22 AM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default create table scripts

In SQL Server you can generate a script from an existing table that will
create another table just like it.
The script contains all the attributes, etc...

Does Access have a feature like that?
I'd like to generate a script for creating a table.

thanks!


  #2  
Old January 23rd, 2006, 02:54 AM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default create table scripts

JET doesn't have a script like that. DDL in JET is hopeless with setting
properties, and the property settings are inconsistent between versions.

The simplest thing to code is:
DoCmd.CopyObject ,"MyNewTable", acTable, "MyTable"
dbEngine(0)(0).Execute "DELETE FROM MyNewTable;"
but that might be inefficient to exeucte if the table has many records.

If you don't mind the user supplying the new name and asking for structure
only:
DoCmd.SelectObject acTable, "MyTable", True
RunCommand acCmdCopy
RunCommand acCmdPaste

In practice, you very rarely create tables in an end-user database. Would it
be feasible to stash a blank copy of the table without data in your original
database as a template, and then use the CopyObject solution when you need
it?


If you really need to write this solution, it would be very lengthy. You
will need a combination of DAO and ADOX, because neither one is able to
create all the field types and properties on its own. Then there is the
Indexes collection of the TableDef, and you may wish to exclude the indexes
that are present only to manage the foreign key field(s) in the relations
that have enforced integrity.


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shank" wrote in message
...
In SQL Server you can generate a script from an existing table that will
create another table just like it.
The script contains all the attributes, etc...



  #3  
Old January 23rd, 2006, 05:35 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default create table scripts

"shank" wrote in news:utX9ZQ8HGHA.524
@TK2MSFTNGP09.phx.gbl:

Does Access have a feature like that?
I'd like to generate a script for creating a table.


There are a lot of db utilities out there for modelling and reverse-
engineering a database, including Jet and SQL Server etc. They will
usually generate DDL for various target platforms. MS Visio is one
example (you need the enterprise edition, I think); Embarcadero have
various products. Try googling for something like "reverse engineer ms
access database".

On the other hand, if you just need to generate the same table on a
regular basis then: (a) you might have a design problem; and (b) it's not
hard to make a DDL command using CREATE TABLE. If you are creating and
pulling down a temp table on a regular basis, then you might be better
off emptying and repopulating the same one in order to reduce bloating
and corruption of the mdb file. Alternatively, make the temp table in a
brand new temporary mdb and erase the whole file afterwards.

Hope that helps


Tim F

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add New Field to DB Karen Database Design 7 October 19th, 2005 08:03 PM
Help again from Ken Snell (Query) Randy Running & Setting Up Queries 22 August 29th, 2005 08:15 PM
Manual line break spaces on TOC or Table of tables Eric Page Layout 9 October 29th, 2004 04:42 PM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM
Table Wizard Does Not Set Relationship if Foreign Key and Primary Key Name Do Not Match Exactly in Case. HDW Database Design 3 October 16th, 2004 03:42 AM


All times are GMT +1. The time now is 12:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.