title: Insert numeric variable into SQL statement
body: <p>How can I insert a numeric variable in a statement from within a stored procedure (here is my attempt):</p>
  
  <pre><code>...
  declare @SQL1 nvarchar(1500)
  declare @calc numeric(18,2)
  Set @calc = 18.00
  SET @SQL1= 'insert into Table1(cv) values(' + @calc + ')' 
  </code></pre>
  
  <p>The error I get on the last line is:</p>
  
  <blockquote>
    <p><em>Error converting data type varchar to numeric.</em></p>
  </blockquote>
  
  <p>If I insert a variable of type <code>nvarchar</code> like this:</p>
  
  <pre><code>SET @SQL1= 'insert into Table1(cn) values(''' + @column_name + ''')' 
  </code></pre>
  
  <p>it works like a charm - but not when I try to insert a numeric field as above in the first example.
  Thank you!</p>
  
  <p>PS: The table Table1 was correctly defined for its columns to match the variable types. Table1 has 2 columns: <code>cn</code> of type <code>nvarchar(50)</code> and <code>cv</code> of type <code>numeric(18,2)</code>. <code>@column_name</code> is <code>nvarchar(50)</code> and <code>@calc</code> is <code>numeric(18,2)</code>.</p>