日期:2014-05-19  浏览次数:20868 次

select读取带有参数的存储过程返回集,求读取语句
写了一个存储过程如下:
CREATE   PROCEDURE   dbo.getPauseDays
        @htongInfoIdx     int
AS
declare   @p1   binary(16)
declare   @p2   binary(16)
create   table   #(c1   text)
insert     #   select   " "
SELECT       @p1       =       textptr(c1)       FROM       #
--声明一个游标
DECLARE       tb       CURSOR       LOCAL          
    FOR      
    SELECT   textptr(   pausedays)
    FROM       hetongpauseinfo   where   uidx   =   @htongInfoIdx
OPEN       tb  
  FETCH       tb       INTO       @p2      
    WHILE       @@fetch_status=0      
    BEGIN      
    UPDATETEXT       #.c1       @p1       NULL       null         hetongpauseinfo.pausedays       @p2      
    FETCH       tb       INTO       @p2      
    END      
    CLOSE       tb      
    DEALLOCATE       tb  
select   c1   from   #
drop   table   #
GO

在查询分析器中   exec getPauseDays   12   可以的到查询的集,但是放在select   语句中怎么也不行了..select   a.*   from   (getPauseDays   12)   as   a   形如这样的读取是不行的吗  


------解决方案--------------------
--一個簡單的示例
use pubs
go

create proc pc
as
select title_id from titles

create table T(col varchar(50))
insert T exec pc

select * from T
------解决方案--------------------
存储过程中包含了select...
------解决方案--------------------
在前台直接執行 exec getPauseDays 12