title: Dynamic SQL (passing table name as parameter)
body: <p>I want to write a stored proc which will use a parameter, which will be the table name.</p>
  
  <p>E.g:</p>
  
  <pre><code>@tablename &lt;&lt; Parameter
  
  SELECT * FROM @tablename
  </code></pre>
  
  <p>How is this possible?</p>
  
  <p>I wrote this:</p>
  
  <pre><code>set ANSI_NULLS ON
  set QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[GetAllInterviewQuestions]
  @Alias varchar = null
  AS
  BEGIN
  Exec('Select * FROM Table as ' @Alias) 
  END
  </code></pre>
  
  <p>But it says incorrect syntax near @Alias.</p>