概述
declare @maxid int
declare @zhibanren nvarchar(30)
declare @shoujihao nvarchar(30)
declare @banci nvarchar(5)
declare @zhibanshijian datetime
select @maxid=ID from safe_message_zhibanbiao where day(getdate())=day(zhibanshijian)
if @maxid<>4
begin
declare Type_Cursor CURSOR FOR select zhibanren,shoujihao,banci,zhibanshijian from safe_message_zhibanbiao where day(getdate())=day(zhibanshijian)
open Type_Cursor
fetch next from Type_Cursor into @zhibanren,@shoujihao,@banci,@zhibanshijian
while(@@fetch_status=0)
begin
insert into safe_message_dangqianzhiban values (@zhibanren,@shoujihao,@banci,@zhibanshijian)
fetch next from Type_Cursor into @zhibanren,@shoujihao,@banci,@zhibanshijian
end
CLOSE Type_Cursor
DEALLOCATE Type_Cursor
end
declare @zhibanren nvarchar(30)
declare @shoujihao nvarchar(30)
declare @banci nvarchar(5)
declare @zhibanshijian datetime
select @maxid=ID from safe_message_zhibanbiao where day(getdate())=day(zhibanshijian)
if @maxid<>4
begin
declare Type_Cursor CURSOR FOR select zhibanren,shoujihao,banci,zhibanshijian from safe_message_zhibanbiao where day(getdate())=day(zhibanshijian)
open Type_Cursor
fetch next from Type_Cursor into @zhibanren,@shoujihao,@banci,@zhibanshijian
while(@@fetch_status=0)
begin
insert into safe_message_dangqianzhiban values (@zhibanren,@shoujihao,@banci,@zhibanshijian)
fetch next from Type_Cursor into @zhibanren,@shoujihao,@banci,@zhibanshijian
end
CLOSE Type_Cursor
DEALLOCATE Type_Cursor
end
转载于:https://www.cnblogs.com/windphoenix/archive/2009/09/03/1559814.html
最后
以上就是虚心寒风为你收集整理的SQL游标循环取值的全部内容,希望文章能够帮你解决SQL游标循环取值所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复