I have a stored procedure which returns a table of data. I need to query certain data from this results.
currently I am doing it as follows:
Create Table #proc
(
[Id] INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
[Name] NVARCHAR(50) NULL,
[MetricName] NVARCHAR(50) NULL,
[Value] NVARCHAR(50) NULL,
[PointsAwarded] NVARCHAR(50) NULL,
[MaxPoints] INT NULL,
[wEIGHTAGE] DECIMAL NULL
)
Insert into #proc
exec dbo.prc_ShopInstanceCustomersData 2023, 10000
select Name, SUM(Case when [PointsAwarded] = 'n/a' then 0 else [PointsAwarded] end) As TotalPoints from #proc group by Name
I dont want to use another extra table here for stored proc results. Is there a way to execute the select query directly from stored procedure results without fetching the results into a table?
Thanks in advance...