Using result sets from a stored procedure

Is it possible to access the result set returned from a stored procedure

For example,

begin
   set @cursor_list = sp_spaceused 'a_table'
   ...loop through here...
end

I can't seem to find any information on accessing the "default result set(s)". Returned from a stored procedure.

What I really want is the output of sp_spaceused for all tables for a particular user.

Thanks
Tory



Answer this question

Using result sets from a stored procedure

  • mAcD

    http://www.sommarskog.se/share_data.html
    
    
    
    
    
    > Is it possible to access the result set returned from a stored
    > procedure 
    >
    > For example,
    >
    > begin
    >  set @cursor_list = sp_spaceused 'a_table'
    >  ...loop through here...
    > end
    >
    > I can't seem to find any information on accessing the "default result
    > set(s)". Returned from a stored procedure.
    >
    > What I really want is the output of sp_spaceused for all tables for a
    > particular user.
    
    
    


  • Noddy

    You can use INSERT EXEC to store the result of stored proc into a temp table.

    create table #t1 (name nvarchar(128), rows varchar(11), reserved varchar(18), data varchar(18), index_size varchar(18), unused varchar(18))

    insert #t1 exec sp_spaceused 'tblTest1'

    <do your loop>

    drop table #t1


  • Carole Akoury

    > What I really want is the output of sp_spaceused for all tables
    
    You could use this undocumented gem:
    
    EXEC sp_MSForEachTable 'EXEC sp_spaceused '' ''' 
    
    
    


  • mralx

    I new the was a newbie question. Thanks for the quick reply.
    Tory

  • Using result sets from a stored procedure