Reputation: 27021
I'm using SQL Server 2005.
My stored procedure returns 100 columns and has 10 pages.
I'd only need to return 5 of the columns and don't want to duplicate the 10 pages of the stored procedure by creating a new stored procedure.
I'd like to avoid defining a new table variable with 100 columns! and I'd like to avoid defining a LinkServer and use OPENROWSET because the server name, etc shouldn't be hardcoded.
Is there any easier/better way?
If so, how to write it? The below code doesn't work:
select ID, Title, (the remaining 3 columns)
from exec dbo.sp_myName
Upvotes: 4
Views: 7621
Reputation: 196
You could create a temp table with all the columns that are returned by the stored procedure, and then use:
Insert Into #TempTable
Exec dbo.sp_myName
Select ID, Title,...
From #TempTable
Upvotes: 1