Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Duplicate a record / many records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Duplicate a record / many records

 Post Reply Post Reply
Author
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Topic: Duplicate a record / many records
    Posted: 19 August 2003 at 5:42am
I want to duplicate records within a table; e.g., find all records where (for example) "Type = 1" and add new records containing the same information in all the other fields but with a new "Type" (say, 9).

I can do a SELECT table.* WHERE table.type = 1

then run through until EOF doing:

strOtherField = rs("OtherField")
(etc for all fields)


then do another rs, adding a new record each time such as,

rs2.Fields("type") = 9
rs2.Fields("OtherField") = strOtherField
(etc for all fields)

rs2.Update

rs.MoveNext
Loop


However, that seems a bit intensive - is there a "Duplicate" command, or some other neater way of doing this?
www.pedalcars.info

The most fun on four wheels

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 19 August 2003 at 6:02am
you can insert information from a table that has been selected from a table using the insert statement
insert into table (fieldname, fieldname2, fieldname3, ... type) select (fieldname, fieldname2, fieldname3, ... 9) from table where type=1
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 19 August 2003 at 10:42am

and just a note:

that's absolutely horrid database design/schema to deep copy almost an entire record...

You're better off having one table of "Type"-s and another with the info and then have a table in between tying together the info rows and the mulitple type rows...... 

my 2 cents anyways

Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.