title: sql stored procedure argument as parameter for dynamic query
body: <p>This procedure has three parameters. But when I try to execute by passing parameters it shows me an error. Please help me.</p>
  
  <pre><code>create procedure queryfunctions @Tabname varchar(150),@colname varchar(150),@valuesname varchar(150)
  as
  begin
  declare @sql varchar(4000)
  select @sql='select * from @Tabname where @colname=@valuesname'
  exec(@sql)
  end
  
  exec queryfunctions 'education','eduChildName','Revathi'
  </code></pre>
  
  <p><strong>Error :</strong> </p>
  
  <blockquote>
    <p>Msg 1087, Level 15, State 2, Line 1
            Must declare the table variable "@Tabname".</p>
  </blockquote>