I want to be able to pass a parameter to a Query to give the names of the tables I am using.
DECLARE @ImportedTable char(100)
DECLARE @EnvTable char(100)
SET @ImportedTable = 'tmpImported'
SET @EnvTable = 'tblDestination'
PRINT @ImportedTable
Select *
From @ImportedTable
When I print the Variable, it looks fine, but when I run the whole thing, the From Clause gives the following error
Must declare the table variable "@ImportedTable".
Why won't it see the variable contents in From Clause?