The most common processing flow:
1. Create a temporary table #tmp, the table structure is compatible with the result set returned by the target stored procedure procedure_name (compatible, not necessarily the same).
CREATE TABLE #tmp(
[columns_list]
)
2. Execute the stored procedure and insert the returned result set of the stored procedure into a temporary table.
INSERT INTO #tmp EXEC procedure_name @parameters_var
3. #tmp can now be used (filtered, changed or retrieved). ^_^
SELECT @querystring =
columns_list FROM #tmp
4. Don't forget to clear the temp table at the end.
DROP TABLE #tmp
Original address: http://www.2cto.com/database/201210/162009.html