我是靠谱客的博主 凶狠大树,这篇文章主要介绍SQL SERVER 游标循环读取表数据,现在分享给大家,希望可以做个参考。

SQL SERVER 游标循环读取表数据

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
declare @a varchar(50),@b int; --定义游标 declare tempIndex cursor for (SELECT a, b from Bdc_Point) --打开游标 open tempIndex --抓取下一行数据给变量,一个或者多个 fetch next from tempIndex into @x, @y --进行循环,0表示抓取成功,1表示抓取失败,2表示不存在抓取行 while @@fetch_status=0 begin -- todo print @x fetch next from tempIndex into @x,@y end close tempIndex --关闭游标 deallocate tempIndex --释放游标

最后

以上就是凶狠大树最近收集整理的关于SQL SERVER 游标循环读取表数据的全部内容,更多相关SQL内容请搜索靠谱客的其他文章。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部