当前位置:网站首页>SQL Server 游标循环表数据
SQL Server 游标循环表数据
2022-04-23 10:24:00 【---清心寡欲---】
实现功能,利用游标循环表数据,并打印出来
表数据内容
实现的思路
实现代码:
declare @id nvarchar(200)
declare @name nvarchar(150)
declare @parentid nvarchar(200)
declare data cursor for
select id,name,parentid from sys_org
open data
fetch next from data into @id, @name, @parentid
while (@@fetch_status = 0)
begin
-- 需要执行的语句
print 'id:'+@id
+' name:'+@name
+' parentid:'+ @parentid
fetch next from data into @id, @name, @parentid
end
close data
deallocate data
执行效果
版权声明
本文为[---清心寡欲---]所创,转载请带上原文链接,感谢
https://blog.csdn.net/ying456baby/article/details/121632686
边栏推荐
- 209. Subarray with the smallest length (array)
- Yarn core parameter configuration
- 二叉树的构建和遍历
- 24、两两交换链表中的节点(链表)
- ansible 云计算 自动化
- DBA common SQL statements (5) - latch related
- Chapter 2 Oracle database in memory architecture (I) (im-2.1)
- C#和数据库连接中类的问题
- 微信小程序简介、发展史、小程序的优点、申请账号、开发工具、初识wxml文件和wxss文件
- 通过流式数据集成实现数据价值(2)
猜你喜欢
2022茶艺师(初级)考试试题模拟考试平台操作
shell脚本免交互
【无标题】
[untitled]
Configuration of LNMP
Six practices of Windows operating system security attack and defense
JUC concurrent programming 07 -- is fair lock really fair (source code analysis)
JUC concurrent programming 06 -- in-depth analysis of AQS source code of queue synchronizer
101. Symmetric Tree
SSH利用私钥无密钥连接服务器踩坑实录
随机推荐
Jerry's factors that usually affect CPU performance test results are: [article]
定义链表(链表)
[untitled]
C#和数据库连接中类的问题
IDEA——》每次启动都会Indexing或 scanning files to index
454. Sum of four numbers (hash table)
59、螺旋矩阵(数组)
C语言——自定义类型
Sim Api User Guide(7)
Redis design and Implementation
Realize data value through streaming data integration (2)
MapReduce core and foundation demo
Sim Api User Guide(4)
域名和IP地址的联系
ARM调试(1):两种在keil中实现printf重定向到串口的方法
Linked list intersection (linked list)
209、长度最小的子数组(数组)
得到知识服务app原型设计比较与实践
Sim Api User Guide(5)
JVM——》常用参数