I am trying to create a procedure that allows for a variable to be used as a table name.
Example:
Select Temp1, Temp2
From @var
The @var has the correct table name but changes with each iteration through the while loop.
-- Above sets up all Variables
WHILE @Count >= @I
BEGIN
SET @ObjectID = (SELECT ObjectID FROM @TmpTable WHERE ID = @I)
SET @TableName = (SELECT TableName FROM @TmpTable WHERE ID = @I)
IF @I = 8
BEGIN
SELECT *
INTO ##TMPTable
FROM @TableName
-- Additional Processing
END
END