title: SQL Server stored procedures to copy tables
body: <p>I have to move a table into other table using a stored procedure by passing the table names as parameters.</p>
  
  <p>Syntax is:</p>
  
  <pre><code>alter procedure [dbo].[moving]
  (
      @to_table varchar(50),
      @from_table varchar(50)
  )
  as
  begin
      EXEC('Select * into '+@to_table+'from '+@from_table)
  end 
  </code></pre>
  
  <p>while executing by.</p>
  
  <pre><code>exec moving newtable,hello
  </code></pre>
  
  <p>It is giving an error:</p>
  
  <blockquote>
    <p>Incorrect syntax near 'hello'</p>
  </blockquote>
  
  <p>pls anyone give solution for this</p>