Sql – Deleting using left join and a table variable


Maybe I'm missing a bracket or something but I'm having a hard time deleting rows from a table variable where I'm left joining and looking for the key I'm joining on. If it has a value, then I get rid of it. The problem is that I can't get the query to parse. Any ideas?

declare @MrTemp 
    key1 int
   ,key2 int

insert into @MrTemp
select key1, key2 from ASourceTable

from @MrTemp mt
left join ARealTable art on mt.key1 = art.key1 and mt.key2 = art.key2 
where art.key1 is not null and art.key2 is not null

Best Solution

FROM @MrTemp mt LEFT JOIN ...