gpt4 book ai didi

sql-server-2008 - 加法更新插入

转载 作者:行者123 更新时间:2023-12-02 08:41:36 26 4
gpt4 key购买 nike

您将如何在 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)

最佳答案

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

关于sql-server-2008 - 加法更新插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2916572/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com