大马资讯论坛 - 马来西亚中文资讯平台
标题:
SQL Server存储过程实现数据迴圈stored procedure foreach row table
[打印本页]
作者:
资讯王
时间:
2011-7-28 22:29
标题:
SQL Server存储过程实现数据迴圈stored procedure foreach row table
SQL Server存储过程实现数据迴圈 stored procedure foreach row returned by query
declare @field1 int
declare @field2 int
declare cur CURSOR LOCAL for
select field1, field2 from sometable where someotherfield is null
open cur
fetch next from cur into @field1, @field2
while @@FETCH_STATUS = 0 BEGIN
--execute your sproc on each row
exec uspYourSproc @field1, @field2
fetch next from cur into @field1, @field2
END
close cur
deallocate cur
复制代码
欢迎光临 大马资讯论坛 - 马来西亚中文资讯平台 (http://freeinfo.com.my/)
Powered by Discuz! X3.3