当前位置: 移动技术网 > IT编程>数据库>MSSQL > 简单实用游标更改数据

简单实用游标更改数据

2019年04月30日  | 移动技术网IT编程  | 我要评论

火玫瑰蜘蛛,年年好节节高,异界海盗王下载

简单实用游标更改数据

 

alter proc updatestudent
@id int,
@id2 int
as
declare @schoolid int
declare @classid int
declare @studentid int
declare @idnumber int
declare @idaaa int
begin
declare feeinsertstudent cursor for 
select stuid,schid,clasid from t_school where id=@id
open feeinsertstudent 
fetch next from feeinsertstudent into @schoolid,@classid,@studentid
while @@fetch_status=0
begin
set @idnumber=(select count(*) from t_leaveschool where studentid=@studentid and schoolid=@schoolid and classid=@classid)
set @idaaa=(select count(*) from t_leaveschool where id=@id2)
if(@idnumber!=0)
if(@idaaa!=0)
begin
update t_leaveschool set studentid=@studentid,classid=@classid,schoolid=@studentid where id=@id2
end
fetch  next from feeinsertstudent into @schoolid,@classid,@studentid
end
close feeinsertstudent
deallocate feeinsertstudent


end

 

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网