fetch first from @sndCur into @tmpCompNo,@tmpCompName
解决方案 »
- 请教从系统表sysprocesses中获取nt_username
- 高手,求SQL语句!
- ADO 服务器间数据传送
- “由于数据移动,未能继续以 NOLOCK 方式扫描”是什么错误,该如何处理?
- SQL2005复制数据库菜单在哪里 exe叫什么
- MSSQL2000某重复行设置
- 如何给SQL2005配置远程连接呢?
- 得到表中的重复记录
- [C++ Error] Unit1.cpp(24): E2288 Pointer to structure required on left side of -> or ->*是啥意思?
- 【求助】一个存储过程中,字符串中含变量和单引号的写法
- 关于备份数据库的问题(init 和 noinit)
- sql server能否自动截断字符串?
从 Transact-SQL 服务器游标中检索特定的一行。语法
FETCH
[ [ NEXT | PRIOR | FIRST | LAST
| ABSOLUTE { n | @nvar }
| RELATIVE { n | @nvar }
]
FROM
]
{ { [ GLOBAL ] cursor_name } | @cursor_variable_name }
[ INTO @variable_name [ ,...n ] ]参数
NEXT返回紧跟当前行之后的结果行,并且当前行递增为结果行。如果 FETCH NEXT 为对游标的第一次提取操作,则返回结果集中的第一行。NEXT 为默认的游标提取选项。PRIOR返回紧临当前行前面的结果行,并且当前行递减为结果行。如果 FETCH PRIOR 为对游标的第一次提取操作,则没有行返回并且游标置于第一行之前。FIRST返回游标中的第一行并将其作为当前行。LAST返回游标中的最后一行并将其作为当前行。...
select sortNo,sortName from pluSort
set @sndCur=Cursor Local Scroll For
select comNo,comName from comInfo where parent=@compNo
open @sndCuropen @firCur
fetch Next From @firCur into @sortNo,@sortNamewhile(@@fetch_status=0)
begin
fetch Next From @sndCur into @tmpCompNo,@tmpCompName
while(@@fetch_Status=0)
begin
.....
fetch Next From @sndCur into @tmpCompNo,@tmpCompName
end
fetch next from @firCur into @sortNo,@sortName
endclose @sndCur
deallocate @sndCur
Clsoe @firCur
deallocate @firCur
set @firCur=Cursor Local Static For
select sortNo,sortName from pluSort
set @sndCur=Cursor Local Scroll For
select comNo,comName from comInfo where parent=@compNo
open @sndCuropen @firCur
fetch Next From @firCur into @sortNo,@sortNamewhile(@@fetch_status=0)
begin
fetch First From @sndCur into @tmpCompNo,@tmpCompName
while(@@fetch_Status=0)
begin
.....
fetch Next From @sndCur into @tmpCompNo,@tmpCompName
end
fetch next from @firCur into @sortNo,@sortName
endclose @sndCur
deallocate @sndCur
Clsoe @firCur
deallocate @firCur