title: Why am I getting 'Error converting data type varchar to numeric' on a floating point number in Perl?
body: <p>We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5) from Perl. As long as the absolute values are .0001 or greater, it is working. However, when the values go to the 5th decimal place, Perl starts storing them in exponential format (<code>-9e-05</code> instead of <code>-0.00009</code>), and then we get the error "<code>Error converting data type varchar to numeric</code>" from SQL Server. How do we prevent that and cause it to properly insert small numeric values?</p>
  
  <p>We are using perl v5.8.5, DBI 1.56, DBD::Sybase 1.07, and SQL Server 2005.</p>
  
  <p>The code is roughly the following, but I have removed the extraneous fields:</p>
  
  <pre><code>$invoice-&gt;{IL_UNITPRICE} = 0.09; # Actually comes from another database
  $invoice-&gt;{IL_PRICEUNITCONV} = 0.001; # Actually comes from another database
  $unitprice = $invoice-&gt;{IL_UNITPRICE} * -1 * $invoice-&gt;{IL_PRICEUNITCONV};
  #$unitprice equals -9e-05 at this point.
  $sth = $dbh-&gt;prepare('INSERT INTO foo ( bar ) VALUES ( ? )');
  $sth-&gt;execute($unitprice);
  </code></pre>
  
  <p>The above line fails with error: <code>DBD::Sybase::st execute failed: Server message number=8114 severity=16 state=5 line=2 server=baz text=Error converting data type varchar to numeric.</code></p>