凌建 回复 history(提问者)ALTER proc array_num
as
set nocount on
declare @i as int;
declare @n as int;
begin
select @i=num from num;
if(@i<2)
begin
set @n=@i+1;
UPDATE [dbo].[num] SET [num] = @n WHERE [num] = @i;
-- select @i;
-- select @n;
select * from num;
end
if(@i=2)
begin
UPDATE [dbo].[num] SET [num] = 1 WHERE [num] = @i;
select * from num;
end
end
先自定义一个存储过程,调用,没查询一次,更新一个值,对应给你查询的条件赋值,根据对应的值来获取你的查询,一次进行遍历,我这是sqlserver上自己定义的 你可以参考修改