我是靠谱客的博主 玩命美女,这篇文章主要介绍存储过程(一张表中的数据插入到另一张表),现在分享给大家,希望可以做个参考。

USE [xcoa]
GO
/****** Object:  StoredProcedure [dbo].[cunchu]    Script Date: 2020/8/15 11:17:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[cunchu]
as

--声明变量(定义变量)
declare @jsr varchar(255)
declare @fid varchar(255)

--建立游标 
DECLARE YOUCURNAME CURSOR FOR select id from xc_lmDetail where jsr='all'  
select @fid=id from xc_lmDetail c where jsr='all'
--打开游标
OPEN YOUCURNAME

--把上面游标里的值赋值给变量
fetch next from youcurname into @fid

--循环
while @@fetch_status<>-1
begin

--反馈表
insert into xc_lmDetailJsr (id,jsr,isquery,fid)values(lower(replace(newId(), '-', '')),'111','WY',@fid)


fetch next from youcurname into @fid
end
--关闭游标
close youcurname
deallocate youcurname

最后

以上就是玩命美女最近收集整理的关于存储过程(一张表中的数据插入到另一张表)的全部内容,更多相关存储过程(一张表中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(122)

评论列表共有 0 条评论

立即
投稿
返回
顶部