[thelist] best method for copying records

Brett Stinson brettastinson at comcast.net
Fri Aug 29 19:22:11 CDT 2003


Chris:
  You do not mention the database you are using, but here is how it can be
done in Access....

INSERT INTO Table2 ( name, [date] )
SELECT Table1.name, Now()
FROM Table1

Now() is a built in Access function, but most other database systems also
have some type of
function to provide the current or "system" date that should work as well.
If not, you could
even use a literal string ('8/29/03') in place of the Now() function if you
had to.
HTH.

Brett Stinson
bstinson at programmer.net <mailto:bstinson at programmer.net>


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org]On Behalf Of Chris W. Parker
Sent: Friday, August 29, 2003 6:50 PM
To: thelist at lists.evolt.org
Subject: [thelist] best method for copying records


Hi.

Ok so I need take some records and copy them from one table to another
table. I've read about SELECT INTO but this doesn't appear to be what I
need. What's the problem you say? Well I'll tell you.

The problem is that I don't want to copy the entire record but I do at
the same time want to INSERT data into the new record. Confusing? Here's
a quick illustration.

I've got two tables:

OldTable

id
name
date

NewTable

id
name
date


I want to take only 'name' from OldTable and put it into NewTable while
at the same time letting the id field in NewTable increment on it's own
(i.e. not taking the value from OldTable) as well as giving
NewTable.date today's date and not what is stored in OldTable.date.

Since SELECT INTO doesn't seem that it will work (although it will and I
just don't know how to use it properly) the only other solution I
thought of was to SELECT the date I do want to keep from OldTable and
then construct a new INSERT INTO query with the old and new data I want
to put in NewTable.


What do you think you people think about this?


You're the best pals a guy could have.
Chris.
--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !




More information about the thelist mailing list