34,575
社区成员
发帖
与我相关
我的任务
分享
set nocount on
create table test(id int, num int)
go
insert into test values(1,100),(2,100)
go
update test set num = num - 60 where id = 1 and num >=60
print '1.1 先减掉 60 ,更新的行数:' + ltrim(@@rowcount)
update test set num = num - 50 where id = 1 and num >=50
print '1.2 先减掉 50 ,更新的行数:' + ltrim(@@rowcount)
go
update test set num = num - 50 where id = 2 and num >=50
print '2.1 先减掉 50 ,更新的行数:' + ltrim(@@rowcount)
update test set num = num - 60 where id = 2 and num >=60
print '2.2 先减掉 60 ,更新的行数:' + ltrim(@@rowcount)
go
select * from test
go
drop table test
go
1.1 先减掉 60 ,更新的行数:1
1.2 先减掉 50 ,更新的行数:0
2.1 先减掉 50 ,更新的行数:1
2.2 先减掉 60 ,更新的行数:0
id num
----------- -----------
1 40
2 50