title: Update column in SQL Server 2008
body: <p>In the following table,i want to update the BreakTime based on comparing the difference betweeen the next record time and current record time.</p>
  
  <p><a href="https://i.stack.imgur.com/Jijur.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jijur.jpg" alt="enter image description here"></a></p>
  
  <p>I have tried this query: </p>
  
  <pre><code>update Machine_Data 
  set BreakTime = (select DATEDIFF(SECOND, M2.Time, M1.Time) as BreakTime 
                   from Machine_Data M1 
                   join Machine_Data M2 on M1.DocEntry = M2.DocEntry + 1) 
  </code></pre>
  
  <p>but it's throws an error </p>
  
  <blockquote>
    <p>Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression.</p>
  </blockquote>