title: SQL Server Stored Procedure insert query with given parameters
body: <p>first of all, sorry for my English,</p>
  
  <p>I am a newbie in stored procedure, so i'm seek for a help on it.</p>
  
  <p>I have a project that need me to create a SP for a configurable table name and column name. I've manage to pass the table name and column name value from vb/vb.net and now i'm stuck on SP, below are sample of my code.</p>
  
  <p>example : </p>
  
  <pre><code>frmTblname = table_a
  frmClmnName = clm_A1, clm_A2, clm_A3, clm_A4, clm_A5,
  toTblName = table_b,
  toClmnName = clmn_b1,clmn_b2, clmn_b3, clmn_b4, clmn_b5
  </code></pre>
  
  <p>from vb/vb.net <em><code>Rslt = ConnectionExec.RunSP(con, "sp_configurable_insert", frmTblname, frmClmnName, toTblName, toClmnName)</code></em></p>
  
  <p><strong>how to add that into SQL insert query?</strong></p>
  
  <p>Here are my SP </p>
  
  <pre><code>CREATE procedure [dbo].[sp_configurable_insert] @fromTable nvarchar(50),@fromColumn nvarchar(4000),@toTable nvarchar(50),@toColumn nvarchar(4000)
  </code></pre>
  
  <p>I've tried this but it seems not giving any result.</p>
  
  <pre><code>set @Query1 = 'insert into '+@toTable+'('+quotename(@toColumn)+')   
      select top 20 '+@fromColumn+' 
  from '+@fromTable+'
  </code></pre>
  
  <p>can anyone help me, please?</p>
  
  <p>Thanks :)</p>