--- create one temp table using temprory talbe
declare @test_Table table (id int, num int, name varchar(50))
--- fetch all data from your table to temp talbe
insert into @test_Table (id,num,name)
select id,number,name from TESTNUMBERS
----select * from TESTNUMBERS
declare @count int
declare @id int
set @count=(select COUNT(1) from @test_Table)
--- create while loop to work on particular row
while (@count <>0)
begin
set id=(select top 1 id from @test_Table)
---- do you task wiht that row and call your stored procedure on this row
---then delete that row form temp table variable
delete from @test_Table where id=@id
--- decarease count to maintain loop
set @count=@count-1
end
您可以使用这种类型的循环来处理每一行而不使用游标。
脚步 :
在临时表中存储数据
获取所有行的计数
在循环中从临时表中获取前 1 行
在该行完成所有任务
den 从临时表中删除该行
将计数减 1
6 如果有帮助,那就尽情享受吧......