title: How to insert DateTime2
body: <p>What is the appropriate way to insert a value into a column of type <code>DATETIME2(7)</code> into SQL Server using a <code>SqlCommand</code>?</p>
  
  <p>Here is what I tried:</p>
  
  <pre><code>DateTime d = new DateTime(2000, 1, 1, 0, 0, 0).AddTicks(1111111);
  
  using (SqlCommand cmd = conn.CreateCommand()) {
      cmd.CommandText = "INSERT DtTest VALUES(@d)";
      cmd.Parameters.AddWithValue("@d", d);
      cmd.ExecuteNonQuery();
  }
  </code></pre>
  
  <p>But when I check the database for the value, I get:</p>
  
  <pre><code>2000-01-01 00:00:00.1100000
  </code></pre>
  
  <p>Which is the value rounded to <code>DATETIME</code> precision.</p>
  
  <p>What do I have to do to get the precise value including the last five digits?</p>