sqlserver 存储过程 游标实例

if exists(select * from sysobjects where id = object_id(N'dbo.test_cursor') and type = 'P')
drop PROCEDURE dbo.test_cursor
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE test_cursor
AS
Declare @acctNbr varchar();
Declare @acctName nvarchar();
Declare MyCursor Cursor
for Select AcctNbr,AcctName From base._Member Order By ID
Open MyCursor
Fetch next From MyCursor
Into @acctNbr,@acctName
while(@@fetch_status=)
     begin
          begin
                Select @acctNbr = Convert(varchar(),@acctNbr)
                Select @acctName = Convert(nvarchar(),@acctName)
                print N'会员卡号:'+@acctNbr + N'-----会员姓名:' + @acctName
          end
          fetch next From MyCursor Into @acctNbr,@acctName
     end
Close MyCursor
Deallocate MyCursor --execute test_cursor
上一篇:如何用eclispe远程调试tomcat--转载


下一篇:50 【Go版本变化】