title: Have this problem with calling stored procedure unknown object type
body: <p>I am trying to write a query that needs to call a stored procedure. But it always throws an error:</p>
  
  <blockquote>
    <p>Unknown object type 'TABLEIXICHistoricalData' used in a CREATE, DROP, or ALTER statement.</p>
  </blockquote>
  
  <p>This is query:</p>
  
  <pre><code>USE ETLCourse
  
  DECLARE @LOOP TABLE 
                (
                    ID INT IDENTITY(1,1),
                    TableName NVARCHAR(100)
                )
  
  INSERT INTO @LOOP (TableName)
      SELECT TABLE_NAME
      FROM INFORMATION_SCHEMA.TABLES 
      WHERE TABLE_NAME LIKE '%_Stocks%'
  
  DECLARE @b INT = 1, @m INT, @t NVARCHAR(100)
  
  SELECT @m = MAX(ID) FROM @LOOP
  
  WHILE @b &lt;= @m
  BEGIN
      SELECT @t = TableName 
      FROM @LOOP 
      WHERE ID = @b
  
      EXECUTE [dbo].[stp_BuildNormalizedTable] @t
  
      SET @b = @b + 1
  END
  </code></pre>
  
  <p>and here is the procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[stp_BuildNormalizedTable]
      @table NVARCHAR(100)
  AS
  BEGIN
      DECLARE @cleanTable NVARCHAR(100),
              @s NVARCHAR(MAX)
  
      SET @cleanTable = REPLACE(@table, '_Stocks', 'HistoricalData')
  
      SET @s = 'CREATE TABLE' + @cleanTable + '(ID INT IDENTITY(1,1), Price DECIMAL(13, 4), PriceDate DATE)
                INSERT INTO' + @cleanTable + '(Price,PriceDate) SELECT [Adj Close],[Date] FROM'
                + @table + ' ORDER BY Date ASC'
  
      --PRINT @s
      EXECUTE sp_executesql @s
  END
  </code></pre>
  
  <p>It should copy two specific column and create a new table by using <code>@Loop</code> table and procedure</p>