Is there anything like table variables in T-SQL?
In Sql Server it looks like this:
DECLARE @ProductTotals TABLE
(
ProductID int,
Revenue money
)
Then in procedure I can:
INSERT INTO @ProductTotals (ProductID, Revenue)
SELECT ProductID, SUM(UnitPrice * Quantity)
FROM [Order Details]
GROUP BY ProductID
And manipulate with this variable like an ordinary table.
Here is description: http://odetocode.com/Articles/365.aspx
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…