Table variables
- Use table variables over temp tables for a small quantity of data (thousands of bytes)
- Example:
DECLARE @product_table TABLE (
product_name VARCHAR(MAX) NOT NULL,
brand_id INT NOT NULL,
list_price DEC(11,2) NOT NULL
);
INSERT INTO @product_table
(
product_name,
brand_id,
list_price
)
SELECT
product_name,
brand_id,
list_price
FROM
production.products
WHERE
category_id = 1;