Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query to copy specific records and append to table with changes

Status
Not open for further replies.

lavaghman

Programmer
Apr 3, 2002
57
AU
Hi there,

I have a table with a primary key and 200 records with the same 'facilityID'

I want to copy these 200 records, change the 'facilityID' for these 200 and append them to my table.

The table also has a primaryKey called 'facilityGoalID' so my 200 copied records will have to have this field changed as well.

What I basically want is 2 instances of the same 200 records (i.e 400 records) but each instance of 200 to have a different 'facilityID'.

Any ideas on a script I could use to achieve this!?

Thanks for the help guys,
regards,
John
 
And which value do you want in facilityGoalID for the copied records ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Don't really care what values go into facilityGoalID as long as they are unique. So guess that'll mean the values need to be sequential from the last facilityGoadID on. Is this possible?

Thanks PHV...appreciate your help!

Regards,
John
 
Buddy,

Write a query something like this,
Insert INto facility
Select facilityID + 1000, othercolumns From facility;

Note:

You can add any number which doesnot create any duplicate with the existing record. here I added 1000..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top