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
);
DECLARE @ListOWeekDays TABLE(DyNumber INT,DayAbb VARCHAR(40) , WeekName VARCHAR(40))
INSERT INTO @ListOWeekDays
VALUES
(1,'Mon','Monday') ,
(2,'Tue','Tuesday') ,
(3,'Wed','Wednesday') ,
(4,'Thu','Thursday'),
(5,'Fri','Friday'),
(6,'Sat','Saturday'),
(7,'Sun','Sunday')
SELECT * FROM @ListOWeekDays
-- 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);