Based on what i think you are trying to do, you need to use exec sp_executesql. Here is an example.
IF OBJECT_ID('tempdb..#MyTempTable') IS NOT NULL DROP TABLE #MyTempTable
CREATE TABLE #MyTempTable
(
Id INT NULL
)
DECLARE @TableName VARCHAR(200) = '#MyTempTable';
DECLARE @Sql NVARCHAR(500) = 'SELECT * FROM ' + @TableName;
EXEC sp_executesql @Sql