Reputation: 16476
As a follow-up to my previous question I would like to know if there is a simple way of doing the following (which doesn't compile):
CREATE TABLE #PV ([ID] INT, [Date] DATETIME, Dis FLOAT, Del Float, Sold Float)
INSERT #PV @ID, exec GetPVSummaryReport @ID, @PID, @From, @To
The reason is I need to join #PV onto another table by [ID], but the original stored procedure doesn't have the necessary parameter.
Updating the SP is difficult (not impossible) as the code is 'out-in-the-wild' and I'd prefer not to have 'GetPVSummaryReport2' (which we already have several of already).
Upvotes: 0
Views: 89
Reputation: 31071
CREATE TABLE #PV ([Date] DATETIME, Dis FLOAT, Del Float, Sold Float)
INSERT #PV EXECUTE GetPVSummaryReport @ID, @PID, @From, @To
SELECT @ID as [ID], * FROM #PV
Or
CREATE TABLE #PV ([ID] INT NULL, [Date] DATETIME, Dis FLOAT, Del Float, Sold Float)
INSERT #PV ([Date], Dis, Del, Sold) EXECUTE GetPVSummaryReport @ID, @PID, @From, @To
UPDATE #PV SET [ID] = @ID
SELECT * FROM #PV
Upvotes: 2