关于fetch

killxtt 2003-08-05 12:20:13
是不是在procedure里面写类似于eof和bof的判断的语句只能用fetch来决定,还有,procedure里面返回的值可以直接返回给asp程序里的参数么?
...全文
43 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengdali 2003-08-05
  • 打赏
  • 举报
回复
--举个例吧,删除所有的用户表:

declare cursor1 cursor for select name from sysobjects where xtype='u'
declare @i varchar(1000)
open cursor1
fetch cursor1 into @i
while @@fetch_status=0
begin
exec('drop table '+@i) --这里
fetch cursor1 into @i
end
close cursor1
deallocate cursor1
Rivulet119 2003-08-05
  • 打赏
  • 举报
回复
可以嵌套。procedure里面返回的值可以直接返回给asp程序里的参数.
killxtt 2003-08-05
  • 打赏
  • 举报
回复
呵呵,多谢,象你刚才写的哪个procedure可以嵌套吗?比如
create procedure aa
declare @b varchar(100)
as
declare @a varchar(200)
declare #aa cursor for select name from sysobjects
open #aa
fetch next from #aa into @a
while @@fetch_status=0
begin
print @a

aa '传送的参数'

fetch next from #aa into @a
end
close #a
deallocate #a
go
zjcxc 元老 2003-08-05
  • 打赏
  • 举报
回复
2.要请ASP高手回答.
zjcxc 元老 2003-08-05
  • 打赏
  • 举报
回复
1.
是的,定义游标用fetch来循环读取.

例子:
create procedure aa
as
declare @a varchar(200)
declare #aa cursor for select name from sysobjects
open #aa
fetch next from #aa into @a
while @@fetch_status=0
begin
print @a
fetch next from #aa into @a
end
close #a
deallocate #a
go

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧