What is the problem with following SQL. Can table variable not be used in JOIN clause?
Error msg is of \"Msg 170, Level 15, State 1, Line 8 Line 8:
Justin's answer is correct syntactically - you need to assign an alias to the temp table (same for table type variables in 2008).
However, be aware that neither table variables nor table-type variables have any statistics associated with them, and therefore can lead the query optimiser to make very dubious choices with regard to execution plans (because it will always estimate that the table variable contains 1 row - and therefore usually chooses nested loops as a join operator).