I want to declare a table variable and I followed the steps in this page but I get error on the line SELECT @StdRevenue;
. It seems that I need to declare the variable - which I did.
The table Purchasing.ProductVendor
:
My code
DECLARE @StdRevenue TABLE
(
ProductID int,
Revenue money
);
--insert values to columns
INSERT INTO @StdRevenue (ProductID, Revenue)
SELECT ProductID, StandardPrice * OnOrderQty
FROM Purchasing.ProductVendor
GROUP BY ProductID;
SELECT @StdRevenue;