sqlserver 存储过程 游标实例
Posted 邹柯
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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(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‘会员卡号:‘[email protected] + N‘-----会员姓名:‘ + @acctName end fetch next From MyCursor Into @acctNbr,@acctName end Close MyCursor Deallocate MyCursor --execute test_cursor
以上是关于sqlserver 存储过程 游标实例的主要内容,如果未能解决你的问题,请参考以下文章