title: updating date by stored procedure
body: <p>I have a problem!</p>
  
  <p>My task is to count the age of books in my library database. After that call some books as too rare, some rare , and usual using value column.</p>
  
  <p>My library table ( ... , age- date , value- date) </p>
  
  <p>notice: "age" - is incorrect definition of a column, it would be better to say "year of publication". Actually my task is to find age!</p>
  
  <p>So, I do this, and my value column does not change :(</p>
  
  <pre><code>create procedure foo 
  as
    declare @bookdate date,
            @currentdate date,
            @diff int
  
    set @currentdate = GETDATE()
  
    select @bookdate =  age from books
  
    select @diff = DATEDIFF (yyyy , @bookdate , @currentdate )
  </code></pre>
  
  <p>Version #1:</p>
  
  <pre><code>  UPDATE books SET value = DATEADD(year,@diff, age)
  </code></pre>
  
  <p>Version #2:</p>
  
  <pre><code>  UPDATE books SET value = @diff  
  </code></pre>
  
  <p>P.S. sorry for any mistakes I made, it is my first step in sql, programming at all, and asking for help in English!</p>