title: Converting varchar to datetime2 in SQL Server
body: <p>I'm using SQL Server 2008 R2 and I did an import from a flat file. I couldn't import the <code>datetime</code> column properly so I specified it temporarily as a <code>varchar(50)</code>. Now I want to convert it to the <code>datetime2</code> format. However when doing so I get the error -</p>
  
  <blockquote>
    <p>Conversion failed when converting
    date and/or time from character
    string.</p>
  </blockquote>
  
  <p>The data that is currently in my <code>varchar(50)</code> column looks like this:</p>
  
  <pre><code>2008-04-02-16.43.32.179530
  2009-01-12-20.15.41.936632
  2009-02-18-16.54.49.071662
  </code></pre>
  
  <p>What's the best way to convert it to <code>datetime2</code>?</p>