Search code examples
sqlsql-server-2005stored-procedures

Can I search stored procedure results?


Let's say I have a stored procedure which returns a large set of data. Can I write another query to filter the result of stored procedure?

For example:

select * from
EXEC xp_readerrorlog
where LogDate = '2011-02-15'

Solution

  • You would need to first insert the results of the stored procedure on a table, and then query those results.

    create table #result (LogDate datetime, ProcessInfo varchar(20),Text text)
    
    INSERT INTO #Result
    EXEC xp_readerrorlog
    
    SELECT *
    FROM #Result
    WHERE datepart(yy,LogDate) = '2012'