table有id,column1 , column2
有数值a
如果a <=column1的值并且a> 0时候则执行update a到column2。
如果要求性能最高的话要怎么写才好,这句要执行很多次,谢谢!
------解决方案--------------------
update table set column2=a where column1> =a and a > 0
------解决方案--------------------
declare @a int
set @a=100
update 表名 set [email protected]
where @a <column1 and @a> 0
------解决方案--------------------
--改一点
declare @a int
set @a=100
update 表名 set [email protected]
where @a <=column1 and @a> 0
------解决方案--------------------
LS可以实现
------解决方案--------------------
--或
declare @a int
set @a=100
if @a> 0
update 表名 set [email protected] where @a <=column1
------解决方案--------------------
怎么变化?
------解决方案--------------------
declare @a int
set @a=100
while @a <column1 and @a> 0
begin
update 表名 set [email protected]
@a --怎么变化呢?
end