| |
|
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.
|
 |

01-23-08, 23:45
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 157
|
|
|
copying multiple rows into the same table with new primary key supplied?
|
|
ei guys,
question, how do i insert multiple rows, (around 40, perhaps) into the same table)
with new primary keys eg.
existing rows
(primary keys being field 1 and field 2)
field 1 field2 field 3
00 a data1
00 b data2
00 c data3
rows to insert to look like this
01 a data1
01 b data2
01 c data3
__________________
Only quitters quit!
|
|

01-24-08, 06:49
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
not sure i understand the question
just go ahead and do the insert as normal
Code:
INSERT
INTO yourtable
( field1, field2, field3 )
VALUES
( 01, 'a', 'data1' )
, ( 01, 'b', 'data2' )
, ( 01, 'c', 'data3' )
|
|

01-27-08, 19:17
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 157
|
|
|
|
I just felt there must be some way for me to copy something like a thousand rows, with 8 - 10 fields each
into a new set of thousand rows with different primary keys from the previous, but exactly the same value in other fields
__________________
Only quitters quit!
|
|

01-27-08, 19:50
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
yes, it's possible, but where would the different primary key values come from?
|
|

01-28-08, 01:40
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 157
|
|
i can just append something to the existing primary key... but i'm confused as to how the form of this query would be... hope you won't mind giving me that?
__________________
Only quitters quit!
|
|

01-28-08, 07:35
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
try this --
Code:
INSERT
INTO yourtable
( field1
, field2
, field3 )
SELECT 01
, field2
, field3
FROM yourtable
|
|

01-28-08, 18:15
|
|
Registered User
|
|
Join Date: Apr 2006
Posts: 157
|
|
aha, i think i see where my problem was
i was using INSERT INTO table () values (SELECT ...);
many thanks, i guess i'm still a big baby with query manipulation, bad dragdown habits from MSAccesss still here
__________________
Only quitters quit!
|
|

01-28-08, 18:32
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
you cannot say INSERT INTO table () values (SELECT ...) in msaccess either
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|