title: adding a table as parameter in a query string in a stored procedure
body: <p>I have the following query :</p>
  
  <pre><code>   ALTER procedure [dbo].[jk_insertAllLocation]
     @locationTbl as locationTable readonly,
     @TableName varchar(100)
     as
     declare @tbl as locationTable,@sql varchar(max)
     begin
          set @sql = 'insert into ' + @TableName +'(location_id,name,address,latitude,longitude,distance,state,sub_cat,id_cat,icon_link,checkinsCount,IDSearch)
          select * from ' +  @locationTbl
          exec sp_executesql @sql
     end
  </code></pre>
  
  <p>I need to pass a table and a table name as parameter and I need to insert in the table name (<code>@TableName</code>) passed as parameter all the data in the table (<code>@locationTbl</code>) passed as parameter</p>
  
  <p>but I know that I cannot concatenate the table (<code>@locationTbl</code>) in the query ... </p>
  
  <p>so how can I fix this?</p>