title: Appending string to SQL Server stored procedure
body: <p>I'm trying to append table name dynamically to SQL Server stored procedure, but I get an error:</p>
  
  <blockquote>
    <p>couldn't find the stored procedure 's'   </p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO    
  SET QUOTED_IDENTIFIER ON    
  GO     
  
  ALTER PROCEDURE [dbo].[atest_demo_sp]    
      @name varchar(10)     
  AS     
  BEGIN     
      Declare @tname nvarchar    
      Declare @sql nvarchar    
  
      set @tname = @name           
      Set @sql = 'select * from ' + convert(varchar(10), @tname)    
  
      -- select @sql     
      execute sp_executesql @sql     
  END
  </code></pre>