【SQL开源代码栏目提醒】:以下是网学会员为您推荐的SQL开源代码-334.sql,希望本篇文章对您学习有所帮助。
use db_
sql declare @编号 varchar(30) /*声明变量*/
declare empcursor cursor for /*创建游标empcursor*/
select 编号 from tb_emp_old16 /*创建游标结果集*/
open empcursor /*打开游标*/
fetch next from empcursor into @编号 /*为变量赋值*/
while ( @@fetch_status=0 ) /*判断FETCH语句是否正确执行*/
begin
declare @ varchar(10),@年龄 varchar(2),@毕业院校 varchar(50)
declare empcursor_2 cursor for /*创建游标empcursor_2*/
select ,年龄,毕业院校 from tb_emp_new16 where 编号 is not null and 编号=@编号
/*为游标赋值*/
open empcursor_2 /*打开游标*/
fetch next from empcursor_2 into @,@年龄,@毕业院校 /*读取游标信息*/
while ( @@fetch_status=0)
begin
begin
update tb_emp_old16 set = @,年龄 = @年龄 ,@
毕业院校 = @毕业院校
where 编号 = @编号 /*修改表中数据*/
end
fetch next from empcursor_2 into @,@年龄,@毕业院校 /*读取游标信息*/
end
close empcursor_2
deallocate empcursor_2 /*释放游标*/
fetch next from empcursor into @编号
end
close empcursor
deallocate empcursor