T-SQL Tip 16: Table Variables
Last tip, T-SQL Tip 12, was on temp tables. Another object that will allow you to hold onto and reuse results is a table variable. These are created with an @ symbol and are created in a declare statement, @ThisIsAVariable. They only persist as long as the batch they are declared in. If you store the results of a query in a table variable, you can use that variable for further queries in your batch....