Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lions1855
Starting Member
4 Posts |
Posted - 2012-06-20 : 09:31:45
|
I have a table [Assets] with several columns. One column name is RetiredDate and second one RemainingDays. I'd like to create a trigger that column RemainingDays is updated by using the future RetiredDate Column and TODAY date.Help much appreciated!Thanks |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-20 : 10:02:18
|
You would need to run that every day which means it couldn't be a trigger (unless you update the table daily).Have you thought of a computed column? Or why not just calculate in the SP when you need to.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
lions1855
Starting Member
4 Posts |
Posted - 2012-06-20 : 11:33:16
|
Basically, I have an internal website that reports some valuable information like the purchase date and the retireddate of the given asset. I also have a column called remainingdays. It would be nice to have this column continuesly updating as the day to get the system needs to be replaces.Thanks |
|
|
lions1855
Starting Member
4 Posts |
Posted - 2012-06-20 : 12:00:42
|
I read online about the compute column. How do use it?quote: Originally posted by nigelrivett You would need to run that every day which means it couldn't be a trigger (unless you update the table daily).Have you thought of a computed column? Or why not just calculate in the SP when you need to.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
|
|
|
lions1855
Starting Member
4 Posts |
Posted - 2012-06-20 : 12:51:55
|
I tried to use this formula in the compute column area and it is telling me that is wrong.=DateDiff("d",Now(),[RetiredDate])Can you take a look please?quote: Originally posted by lions1855 I read online about the compute column. How do use it?quote: Originally posted by nigelrivett You would need to run that every day which means it couldn't be a trigger (unless you update the table daily).Have you thought of a computed column? Or why not just calculate in the SP when you need to.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.
|
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-21 : 03:55:52
|
DateDiff(dd,getdate(),[RetiredDate])Have a look in bol (books online)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|