SQL——游标循环的写法

sql里写循环,还是得用游标写。

 

 

 

插入代码

--cs
declare @CLID varchar(50),@Start varchar(200),@End varchar(200);
declare cs cursor for select CLId,Start,[End] from #tCiLian
open cs
fetch next from cs into @CLId,@Start,@End

--cs
while @@FETCH_STATUS =0
begin
select @CLID
  fetch next from cs into @CLId,@Start,@End
end

--cs
close cs
deallocate cs

完了

 

posted @ 2020-05-04 18:58  法宝  阅读(378)  评论(0编辑  收藏  举报