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!

Merge Into with multiple execution 1

Status
Not open for further replies.

TheLazyPig

Programmer
Sep 26, 2019
95
PH
Hi!

I would like to know if I can use merge with multiple executions when matched.

When matched, it should insert the matched record into a history table first and then update the main table.
When not matched, it will insert into the main table.

I just wanted to back up the matched record for history.



Thanks!
 
I'm not aware of any way to do this (a more clever person will soon post a fine solution, I'm sure). In the meantime, I think you'll need to take the more traditional approach of either using two statements (merge the main table, insert the history table) or put a trigger on the main table that maintains the history table. Hoping the more clever person comes along to enlighten us both.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top