sql - 当我们使用加法赋值 (+=) 时更新空值
问题描述
declare @temp table
(
Id int,
Qty int
)
insert into @temp values(1,null)
update @temp set Qty+=2
select * from @temp
我正在尝试更新该Qty
列,但该Qty
列默认为空。因此,因为当我尝试更新时生产数据库列可能为空,所以我得到一个空值,我需要Qty
为 2。
declare @temp table
(
Id int,
Qty int
)
insert into @temp values(1,null)
update @temp set Qty+=2
select * from @temp
我正在尝试更新该Qty
列,但该Qty
列默认为空。因此,因为当我尝试更新时生产数据库列可能为空,所以我得到一个空值,我需要Qty
为 2。
标签: sqlsql-servertsqlsql-server-2012