title: Converting this varchar to a decimal with the appropriate decimal point?
body: <p>I've been playing with cast()s and such with this and can't seem to get things to work.  I have a varchar string that's 18 characters long that I'd like to convert or cast to a decimal, with five decimal places.  So for instance, this string:</p>
  
  <p>00000001987600130</p>
  
  <p>Would become 19876.00130</p>
  
  <p>It's the case that I'll always have a 17 character string, with the last five characters reserved as the decimal place. </p>
  
  <p>I've been playing with casts and converts but I'm not quite there.  For instance, these statements get me (sort of) close but not exactly.</p>
  
  <pre><code>select CAST('00000001987600130' as bigint)/100000.0
  
  select (convert(decimal(17,5),left('00000001987600130',12),0))
  </code></pre>
  
  <p>If you have a suggestion I'm happy to try it.  Thanks!</p>