游标:create proc a
@1 cursor varying out,
@2 cursor varying out
as
declare b cursor local for select * from table1
declare c cursor local for select * from table1
open b
open c
set @1=b
set @2=c
godeclare @a cursor,@b cursorexec a @a out,@b out
fetch @a
fetch @b
fetch @b
fetch @b
fetch @aclose @a
close @bdeallocate @a
deallocate @bdrop proc a
@1 cursor varying out,
@2 cursor varying out
as
declare b cursor local for select * from table1
declare c cursor local for select * from table1
open b
open c
set @1=b
set @2=c
godeclare @a cursor,@b cursorexec a @a out,@b out
fetch @a
fetch @b
fetch @b
fetch @b
fetch @aclose @a
close @bdeallocate @a
deallocate @bdrop proc a
create proc p_test
as
select name from sysobjects
as--调用它上面存储过程的结果集
create table #t(name sysname) --创建临时表,保存存储过程的调用结果
insert into #t exec p_test
select * from test
create table #t(name sysname) --创建临时表,保存存储过程的调用结果
insert into #t exec p_test
select * from #t
select * from p_test(@id,getdate()) where age>80