upsert with addition

Posted by cf_PhillipSenn on Stack Overflow See other posts from Stack Overflow or by cf_PhillipSenn
Published on 2010-05-26T20:34:33Z Indexed on 2010/05/26 20:41 UTC
Read the original article Hit count: 293

Filed under:

How would you write the following in Microsoft SQL Server 2008?

IF EXISTS(SELECT * FROM Table WHERE Something=1000)
UPDATE Table SET Qty = Qty + 1 WHERE Something=1000
ELSE
INSERT INTO Table(Something,Qty) VALUES(1000,1)

© Stack Overflow or respective owner

Related posts about sql-server-2008