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(100);
Declare @acctName nvarchar(100);
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=0)
     begin
          begin
                Select @acctNbr = Convert(varchar(100),@acctNbr)
                Select @acctName = Convert(nvarchar(100),@acctName)
                print N'会员卡号:'+@acctNbr + N'-----会员姓名:' + @acctName
          end
          fetch next From MyCursor Into @acctNbr,@acctName
     end
Close MyCursor
Deallocate MyCursor

--execute test_cursor

 

相关文章:

  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-06-08
相关资源
相似解决方案