ms sql server 游标

很简单的一个小例子。

/****** Object:  StoredProcedure [dbo].[usp_test]    Script Date: 10/28/2016 15:08:31 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[usp_test]
    
as
declare @sRYBM varchar(20),@sJGBM varchar(20)

declare sCursor cursor for select rybm,jgbm from  sys_czry --for xml path('')---操作人员表
open sCursor

fetch next from sCursor into @sRYBM,@sJGBM

 While(@@Fetch_Status = 0)
 begin
    print @sRYBM+' '+@sJGBM
    fetch next from sCursor into @sRYBM,@sJGBM
 end
close sCursor
Deallocate sCursor

GO
原文地址:https://www.cnblogs.com/hoaprox/p/6008199.html