Friday, 2 October 2009

Querying the results of a stored procedure

If you want to run a query against the results of a stored procedure a simple solution is to use a temporary table and the “INSERT INTO” SQL syntax. For example:

CREATE TABLE #MyTempTable (
     some_field varchar(10),
     some_other_field varchar(40)
)

INTERT INTO #MyTempTable
     EXEC my_stored_procedure

SELECT * FROM #MyTempTable WHERE some_field LIKE '%some value%'
    
DROP TABLE #MyTempTable
GO

0 comments:

Post a Comment

By all means leave a comment. I may not be able to get back to you as quickly as I'd like but I'll do my very best.