select @@VERSION as 版本
sql游标的使用
原创lijiazhiaijj ©著作权
©著作权归作者所有:来自51CTO博客作者lijiazhiaijj的原创作品,请联系作者获取转载授权,否则将追究法律责任
select @@LANGUAGE as 语言
go
select * from kc
declare yb insensitive cursor --定义静态游标
for
select * from xs
open yb --打开游标
if @@ERROR=0 --判断游标是否打开成功0为成功,其失败
begin
print '学生总数:'+convert(varchar(3),@@cursor_rows) --@@cursor_rows 统计游标的行数
end
close yb --关闭游标
deallocate yb --释放游标
declare yb scroll cursor --定义滚动游标
for
select * from xs
open yb --打开游标
fetch next from yb --读取一行(向下)
fetch prior from yb --读取一行(向上)
fetch first from yb --读取第一行
fetch last from yb --读取最后一行
fetch relative 1 from yb --相对引用(当前的下一个)
fetch absolute 1 from yb --绝对引用(游标的第一个)
close yb --关闭游标
deallocate yb --释放游标
fetch next from yb
while @@fetch_status=0
fetch next from yb
--修改当前记录
update kc
set 学分=4
where CURRENT OF yb
close yb
deallocate yb
--删除当前记录
delete from kc
where current of yb
下一篇:C#实现接口类型
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
SQL数据库入门06:游标、存储过程的操作及T-SQL程序设计
本文介绍基于Microsoft SQL Server软件,实现数据库T-SQL语言程序设计,以及游标的定义、使用与存储过程的创建、信息查找的方法~
SQL 数据库 SQL Server MySQL 存储过程 -
SQL Server游标的使用
游标是邪恶的! 在关系数据库中,我们对于查询的思考是面向集合的。而游标打破了这一规则,游标使得我们思考方式变为逐行进行.对于
SQL Server 游标 使用 数据 -
SQL中游标的使用
一般情况下,我们用SELECT这些查询语句时,都是针对的一行记录而言, 如果要在查询分析器
sql 数据 赋值 查询分析器 -
SQL游标的使用(转载)数据 批处理 sed 动态游标 结果集
-
sql 使用游标的小例子
create proc Test as begin declare @number int declare @strtest varchar(30)
职场 数据库 休闲 sql 使用游标的小例子