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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I copy one table to another.



 
 
Thread Tools Display Modes
  #1  
Old February 21st, 2010, 10:07 PM posted to microsoft.public.access.queries
Dennis
external usenet poster
 
Posts: 1,222
Default How do I copy one table to another.

Hi,

I am finshing up an major upgrade for some church membership project I'm
working on.

I have added a LOT of new fields to the tblMembership table. I want to copy
the data in the old tblMembership table to the new tblMembership table. The
new tblMembership table is empty.

Specifically, how would I do this? A sample SQL statement would be most
helpful.

Thanks

Dennis


  #2  
Old February 21st, 2010, 10:12 PM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default How do I copy one table to another.

hi Dennis,

On 21.02.2010 23:07, Dennis wrote:
I have added a LOT of new fields to the tblMembership table. I want to copy
the data in the old tblMembership table to the new tblMembership table. The
new tblMembership table is empty.

Specifically, how would I do this? A sample SQL statement would be most
helpful.


INSERT INTO newTable (fieldList)
SELECT fieldlist
FROM oldTable


mfG
-- stefan --
  #3  
Old February 21st, 2010, 11:01 PM posted to microsoft.public.access.queries
Dennis
external usenet poster
 
Posts: 1,222
Default How do I copy one table to another.

Stefan,

I entered this into query builder in SQL mode / view:

INSERT INTO tblMailingList-Prod-18 (CanteenNo)
SELECT CanteenNo
FROM tblMailingList-Prod;


When I tried to swith to Query Design view, I received the error message
"Syntax error in INSERT INTO statement". Any suggestions?

Thanks,

Dennis

  #4  
Old February 21st, 2010, 11:25 PM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default How do I copy one table to another.

Dennis:

You need to wrap the table name in square brackets as it includes the hyphen
characters. Table or field name which include spaces or special character
need to be bracketed like this. If in doubt include the brackets.

If your new table includes all the original columns of the old table, with
the same names, you don't in fact need to include a column list. You can use
an asterisk to denote all columns and the query will then append the values
from them all into the same named columns in the new table and leave the new
columns empty:

INSERT INTO [tblMailingList-Prod-18]
SELECT *
FROM [tblMailingList-Prod];

Make sure that none of the new columns have their Required property set to
True (Yes), or if it is, have the DefaultValue property set to something
appropriate. Otherwise the 'append' query will fail.

Ken Sheridan
Stafford, England

Dennis wrote:
Stefan,

I entered this into query builder in SQL mode / view:

INSERT INTO tblMailingList-Prod-18 (CanteenNo)
SELECT CanteenNo
FROM tblMailingList-Prod;

When I tried to swith to Query Design view, I received the error message
"Syntax error in INSERT INTO statement". Any suggestions?

Thanks,

Dennis


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1

  #5  
Old February 22nd, 2010, 12:08 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default How do I copy one table to another.

On Sun, 21 Feb 2010 14:07:01 -0800, Dennis
wrote:

Hi,

I am finshing up an major upgrade for some church membership project I'm
working on.

I have added a LOT of new fields to the tblMembership table.


That statement makes my neck hairs bristle. VERY few tables need "a LOT" of
fields! "Fields are expensive, records are cheap"; if you're adding a lot of
Yes/No fields or few-choice fields, you may well have "committed spreadsheet",
and may be better off adding a new *table* related one to many to
tblMembership. What sort of fields do you mean?

I want to copy
the data in the old tblMembership table to the new tblMembership table. The
new tblMembership table is empty.

Specifically, how would I do this? A sample SQL statement would be most
helpful.


An Append query will let you add *all the new fields at one go*, not just one
field at a time as in your response in this thread. We can't see your tabl or
fieldnames from here, but the syntax would be something like

INSERT INTO tblMembershipNew([thisfield], [thatfield], [anotherfield], etc
through all the fields you want to migrate into)
SELECT [this], [that], [another], etc. FROM tblMembershipOld;

The details will of course depend on the structure of the tables, and since
your new fields do not have any corresponding field in the old table, they
will need to either be left NULL to be filled in manually later, or with some
sort of default or calculated value.
--

John W. Vinson [MVP]
  #6  
Old February 22nd, 2010, 01:45 AM posted to microsoft.public.access.queries
Dennis
external usenet poster
 
Posts: 1,222
Default How do I copy one table to another.


Ken,

That worked great!

And thats for the explanation. I learned a little a little more each date.

Thanks for the help.

Dennis


  #7  
Old February 22nd, 2010, 04:29 AM posted to microsoft.public.access.queries
Dennis
external usenet poster
 
Posts: 1,222
Default How do I copy one table to another.

John,

My Comment “I am finishing up an major upgrade for some church membership
project. I have added a LOT of new fields to the tblMembership table. “

Your Response “That statement makes my neck hairs bristle. VERY few tables
need "a LOT" of fields! “

My Response: I added about 30 fields. The first release worked so well, the
user want to greatly expand that data that was being collected. As a result,
we added about 20 to 30 data fields. The updated member record has about 70
fields.

I have to disagree with you regarding the comment “VERY few tables need a
lot of field”. I’ve been developing commercial insurance processing system
using relational databases and third normal form for about 30 year. Some
policy, claims, and reinsurance tables can contain a lot of data with a lot
of fields. Obviously, projects of that size do not belong on Access. With
respect to Access, you are probably correct.


Your Response: "Fields are expensive, records are cheap"; if you're adding a
lot of Yes/No fields or few-choice fields, you may well have "committed
spreadsheet",

My Response: I don’t understand “Fields are expensive, records are cheap.”
It has been my understanding that you want to minimize the number of time you
go to the hard drive, especially over the network. With other databases, it
has been my experience that “Fields are cheap, records are expensive”. What
makes Access an exception to this?

I don’t know what you mean by “committed spreadsheet”.

Are you trying to tell me that Access works better if I break up a large
master record into multiple small master records in multiple tables?


Your Response “and may be better off adding a new *table* related one to
many to tblMembership. What sort of fields do you mean?”

My Response: Why would I create a new table relating one to many when all
tables are already in third normal form? The data in each row is a property
of the member and is in a one to one relationship.


Your comment “An Append query will let you add *all the new fields at one
go*, not just one field at a time as in your response in this thread. We
can't see your table or fieldnames from here, but the syntax would be
something like

My Comment: I stated that wanted to copy all of the fields from my old
table to the new table. When it did not work, I used a simpler version so I
could provide the exact syntax in the hope that someone could tell me what I
did wrong.

Ken Sheridan’s response resolved my issue. I wanted to copy all of the
existing fields from the old table to the new table. You are correct in that
I have a series of update queries to fill in some of the new data fields.
For the other new data fields, there will be nothing in them until the users
enters the data.


Thanks for you comment. I learn something for everything I read. Thanks
again. I hoped I explained my thought process.



Dennis
 




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


All times are GMT +1. The time now is 10:35 AM.


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