DECLARE @table_variable_name TABLE (
column_list
);
Example:
DECLARE @product_table TABLE (
product_name VARCHAR(MAX) NOT NULL,
brand_id INT NOT NULL,
list_price DEC(11,2) NOT NULL
);
-- name type value
DECLARE @PersonId AS UNIQUEIDENTIFIER = 'ddb7bfff-9ce8-4651-6973-08d9a46c90b6'
DECLARE @TABLE TABLE( COL1 INT, COL2 VARCHAR(30))
DECLARE @datecurrent datetime2
set @datecurrent = CAST(getdate() AS smalldatetime)
DECLARE @TableVariable TABLE (Id INT)
INSERT INTO @TableVariable
SELECT Id
FROM TableName
WHERE....
SELECT *
FROM TableName
WHERE Id IN ( SELECT Id FROM @TableVariable)
DECLARE @COURSE_ID AS INT, @COURSE_NAME VARCHAR (10);