--测试代码
declare @tb table(int int identity(1,1),s int)
insert @tb
select 400 union all
select 100 union all
select 550 union all
select 620 union all
select 123
select * from @tb
update @tb set s = s - 500 where s > 500 and s < 600
select * from @tb
/*
更新前的数据
nt s
----------- -----------
1 400
2 100
3 550
4 620
5 123
更新后的数据
int s
----------- -----------
1 400
2 100
3 50
4 620
5 123
drop table test
create TABLE test
(a int,b int, c int)
insert into test values('100','300','400')
insert into test values('200','500','400')
insert into test values('300','600','400')
insert into test values('400','700','400')
insert into test values('500','600','400')
insert into test values('600','800','400')
create procedure Hd_SP_test(
@x int , @y int)
AS
declare @a int, @b int
declare TempCur scroll cursor
for
select a,b from test
open tempcur
fetch first from tempcur into @a, @b
while @@fetch_status =0
begin
if (@b>@x) and (@b<@y)
update test set b=@b-@x where a=@a
fetch next from tempcur into @a, @b
end