title: How to use variable in FROM clause in SQL Server query?
body: <p>I am creating a query that will select all data on the table. The query will select to the table base on the variable that I will pass on the stored procedure.</p>
  
  <p>Here in my example. If I execute <code>example_sp table1</code> it will select in <code>table1</code>. Same thing if I use <code>example_table table2</code>, it should select<code>table2</code>.</p>
  
  <pre><code>ALTER PROCEDURE example_sp
      @type varchar(10), -- value will be `table1` or `table2`
  AS
  BEGIN
      SELECT * FROM @type
  END
  </code></pre>