title: sql type conversion
body: <p>I have a column datedocumented in the format YYYYMMDD and of the datatype nvarchar. I want to change the data type to datetime and update the column name exdatedocumented and alter the table using ALTER .can anyone help in this.I have tried something like this </p>
  
  <pre><code>update dbo.table2
  set [DateDocumented] = convert(datetime,CAST([DateDocumented] as datetime),130)
  </code></pre>
  
  <p>I ended up getting error </p>
  
  <pre><code>Msg 242, Level 16, State 3, Line 1
  The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
  The statement has been terminated
  </code></pre>
  
  <p>.</p>