title: T-SQL How to update the bottom/last row only?
body: <p>I want to update the bottom/the last row in my table. I have try to implement <a href="https://stackoverflow.com/questions/1198364/how-can-i-update-top-100-records-in-sql-server">this</a> solution, but nothing seems as correct syntax:</p>
  
  <pre><code>UPDATE TOP(1) @ResultTable
  SET PeriodLastDate=DATEADD(DAY,-1,PeriodLastDate)
  ORDER BY PeriodID DESC
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>UPDATE TOP(1) @ResultTable
  SET PeriodLastDate=DATEADD(DAY,-1,PeriodLastDate)
  FROM @ResultTable
  ORDER BY PeriodID DESC
  </code></pre>
  
  <p>What I have till now working is:</p>
  
  <pre><code>UPDATE @ResultTable
  SET PeriodLastDate=DATEADD(DAY,-1,PeriodLastDate)
  WHERE PeriodID=(SELECT COUNT(PeriodID) FROM @ResultTable)-1
  </code></pre>
  
  <p>but this will not always works, as in my function some of the records are deleted and I am not always having PeriodIDs incremented with 1.</p>