In SQL Server 2012, Is there a way to create a table variable that references a table already in the database? Note: I have a string variable that contains the name of the table.
DECLARE @tablename As varchar(MAX)
DECLARE @TB As Table
SET @tableName = 'table1'
SET @TB = table with name 'table1'
SELECT * FROM @TB
Note: I'm asking if I could do this without dynamic sql, I already know that I could do 'EXEC sp_executesql 'SELECT * FROM ' + @tableName.