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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a record, then Insert same record but diff data 1

Status
Not open for further replies.

JohnnyLong

Programmer
Sep 27, 2002
97
GB
Hi Everyone,

Can somebody please tell me how to SELECT a record from a table and then INSERT the same record to the same table but with a small change to the data.

Like this:

SELECT *
FROM rc_Events
WHERE ContactID = 10038214

INSERT
INTO rc_Events(EventType, Subject, ClientID, CandidateID,OrderID, ContactID, PlacementID, InterviewID, CVID, ReferenceID, CompletedFlag, CreatedDate, CreatedBy,
ModifiedDate, ModifiedBy)
VALUES (EventType, Subject, ClientID, CandidateID, OrderID,
10038295, PlacementID, InterviewID, CVID, ReferenceID,
CompletedFlag, CreatedDate, CreatedBy, ModifiedDate,
ModifiedBy)

rc_Events has an Identity increment of 1

I'm basically trying to Insert a 'copy' of a record but with a different ContactID.

This is in SQL 7

Thanks,

John
 
insert into rc_Events
(
EventType, Subject, ClientID, CandidateID, OrderID,
ContactID, PlacementID, InterviewID, CVID, ReferenceID,
CompletedFlag, CreatedDate, CreatedBy, ModifiedDate,
ModifiedBy
)
(select EventType, Subject, ClientID, CandidateID, OrderID,
10038295, PlacementID, InterviewID, CVID, ReferenceID,
CompletedFlag, CreatedDate, CreatedBy, ModifiedDate,
ModifiedBy FROM rc_Events
WHERE ContactID = 10038214)

Hope this works.
If this will be a regular thing you may want to create a stored procedure where you pass in the contactid f the record you want to copy, and what you want its new ccontactID to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top