Sql游标
ALTER proc [dbo].[FirstCreatePayFuture]
as
declare @identity_id nvarchar(50);
declare @count int;
set @count=0;
DECLARE vendor_cursor CURSOR FOR select distinct identity_id from dbo.T_Bills tb where tb.identity_id!=''
OPEN vendor_cursor --打开游标
FETCH NEXT FROM vendor_cursor INTO @identity_id --遍历数据
while (@@FETCH_STATUS = 0) --判断状态,0没有错误
begin
set @count=@count+1;
print @identity_id;
FETCH NEXT FROM vendor_cursor INTO @identity_id --遍历数据
end
CLOSE vendor_cursor --关闭游标
DEALLOCATE vendor_cursor --释放资源
print @count;
--使用游标 end
as
declare @identity_id nvarchar(50);
declare @count int;
set @count=0;
DECLARE vendor_cursor CURSOR FOR select distinct identity_id from dbo.T_Bills tb where tb.identity_id!=''
OPEN vendor_cursor --打开游标
FETCH NEXT FROM vendor_cursor INTO @identity_id --遍历数据
while (@@FETCH_STATUS = 0) --判断状态,0没有错误
begin
set @count=@count+1;
print @identity_id;
FETCH NEXT FROM vendor_cursor INTO @identity_id --遍历数据
end
CLOSE vendor_cursor --关闭游标
DEALLOCATE vendor_cursor --释放资源
print @count;
--使用游标 end