How to use T-SQL MERGE in this case?
Posted
by abatishchev
on Stack Overflow
See other posts from Stack Overflow
or by abatishchev
Published on 2010-06-03T16:26:29Z
Indexed on
2010/06/03
16:44 UTC
Read the original article
Hit count: 193
I'm new to T-SQL command MERGE
so I found a place in my SQL logic where I can use it and want to test it but can't figure out how exatcly should I use it:
IF (EXISTS (SELECT 1 FROM commissions_history WHERE request = @requestID))
UPDATE commissions_history
SET amount = @amount
WHERE request = @requestID
ELSE
INSERT INTO commissions_history (amount) VALUES @amount)
Plase suggest the proper usage. Thanks!
© Stack Overflow or respective owner