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 imposs开发者_运维百科ible) as the code is 'out-in-the-wild' and I'd prefer not to have 'GetPVSummaryReport2' (which we already have several of already).
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
精彩评论