There is no way in SQL Server to create a temporary table on the fly from the results of a stored procedure, ala:
CREATE TABLE
EXEC spMyStoredProc
or
EXEC spMyStoredProc INTO
or something like that. Instead, you need to know the layout of the SP in advance, and you need to do something like this:
CREATE TABLE
INSERT INTO
EXEC spMyStoredProc
Is there a functional reason why this is so? Maybe a limitation of SQL Server? Or is it just something that has not yet been added to the SQL specification, and I can express the hope that one day they will support it?
source
share