I have a problem!
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.
My library table ( ... , age- date , value- date)
notice: "age" - is incorrect definition of a column, it would be better to say "year of publication". Actually my task is to find age!
So, I do this, and my value column does not change :(
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 )
Version #1:
UPDATE books SET value = DATEADD(year,@diff, age)
Version #2:
UPDATE books SET value = @diff
P.S. sorry for any mistakes I made, it is my first step in sql, programming at all, and asking for help in English!