[thelist] best method for copying records

rudy rudy937 at rogers.com
Fri Aug 29 19:17:27 CDT 2003

hi chris

      into newtable
         ( name
         , thedate )
    select name
         , current_date
      from oldtable

the id field is omitted so that it gets incremented automatically

some databases let you supply a null for it, in order to achieve the
same effect (getting it to increment), but all of the ones i'm familiar with
will work correctly when you don't mention the incrementing column

you did not specify which database you're using, so i used "current_date"
which is the sql standard -- supported by mysql, but you may need to use
date() in access, getdate() in sql server, etc.

i'm sure you used those column names only as examples, but i shall point out
anyway that you should never use a reserved word like "date" as a column


More information about the thelist mailing list