Table variable error: Must declare the scalar variable "@temp"
Either use an Allias in the table like T and use T.ID, or use just the column name.
declare @TEMP table (ID int, Name varchar(max))
insert into @temp SELECT ID, Name FROM Table
SELECT * FROM @TEMP
WHERE ID = 1
A table alias cannot start with a @
. So, give @Temp
another alias (or leave out the two-part naming altogether):
SELECT *
FROM @TEMP t
WHERE t.ID = 1;
Also, a single equals sign is traditionally used in SQL for a comparison.