循环当中应该是:fetch next from student_cursor into @name,@st_id
解决方案 »
- 我需要个 sql server的QQ交流群啊
- 如何清除sql server企业管理器->管理->sql server日志中的日志?
- 一个棘手的存储过程问题.希望能够得到老师们的帮助!
- 如何替换列中的字段
- 触发器求解,谢谢大家!
- 一个sql问题,类似树的遍历
- [留言簿系统] 我如何能通过一次查询查处所有递归的发言引用呢?
- SQL SERVER 2000 ,如何提供互联网查询服务,(最好有现成的样例的,无内容)
- 我不想买盗版光碟,太贵了,请问……
- SQL通过一个表查到的结果当做另外一个表要查询的字段 怎么弄
- 存储过程的返回值
- 安装SQL SERVER 2000时候出现下面提示,请问如何解决?详细请进!
declare @name char(20),@st_id char(20)
declare student_cursor cursor for
select 姓名,学号 from xs
open student_cursor
fetch next from student_cursor into @name,@st_id
select @name,@st_id
while @@fetch_status=0
begin
fetch next from student_cursor into @name,@st_id
-------------------------------------^^^^^^^^^^^^^^^^^
select @name,@st_id
end
close student_cursor
deallocate student_cursor
结果是对的。
但是循环当中是:fetch next from student_cursor 结果就有问题了。也能将表中记录从头显示,只是显示的是:第一条记录,第二条,第一条,第三条,第一条,第四条。这是为什么?
而当循环当中是:fetch next from student_cursor时游标会自动显示数据,
而@name,@st_id中数据没变你循环中的“select @name,@st_id”也会显示但一直显示的是第一条数据,所以