sql sever while问题 我是一个新手写了2段sql语句为什么第一个报错第二个就不会报错求各位帮忙谢谢。
select * from Table_1//表按照money的升序排列
order by money asc
declare @int int
select @int = min(money) from Table_1 //变量赋值为最小的money
while((@int <20)
begin
update Table_1 set money =money+2//跟新money的值加2
select @int = min(money) from Table_1 //重新给@int赋值
end
select * from Table_1
order by money asc
第二段可以执行
select * from Table_1
order by money asc
declare @int int
select @int =count(*) from Table_1 where money<20//money小于20的行数
while (@int>0)
begin update Table_1 set money =money+2//跟新money的值加2
select @int =count(*) from Table_1 where money<20 //重新给@int赋值
end
select * from Table_1
order by money asc
------最佳解决方案-------------------- select * from Table_1//表按照money的升序排列
order by money asc
declare @int int
select @int = min(money) from Table_1 //变量赋值为最小的money
while((@int <20)这里多了个左括号
begin
update Table_1 set money =money+2//跟新money的值加2
select @int = min(money) from Table_1 //重新给@int赋值
end
select * from Table_1
order by money asc ------其他解决方案-------------------- 还是你细心顺便问下怎么设置错误自动提示啊 ------其他解决方案-------------------- 啥叫自动提示? ------其他解决方案--------------------