HLRosenberger
asked on
Help with a trigger or computed column
I had already asked this, and then closed the case. However, I realize the answer I accepted did not work. So.....
I have a table with an end date column and a long value that is a status. I want to set the status to a specific value whenever the current date is great than the end date.
A computed column will not work, unless I do not understand something. A computed column is just that - always computed. What I need to do is automatically update a non-computed status column based on the fact that the current date is greater than the EndDate column. My non-computed status column is also updated via code based on other factors.
I have a table with an end date column and a long value that is a status. I want to set the status to a specific value whenever the current date is great than the end date.
A computed column will not work, unless I do not understand something. A computed column is just that - always computed. What I need to do is automatically update a non-computed status column based on the fact that the current date is greater than the EndDate column. My non-computed status column is also updated via code based on other factors.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
All computed columns are computed when they are accessed, not updated
Pointless, because a trigger does not "look". The trigger only fires if there is an insert or an update. it is not something that's continuously monitoring your records. nor is it aware of the passage of time. That is why I initially asked if you want your status updated on schedule, or at the time of insert/update - in the former case you would use a scheduled SQL Agent job, in the latter - a trigger.
ASKER
On insert or update will not work I guess because no insert or update is being done. The record already exists and I need to update the status column based on a comparing the GetDate() with the EndDate column.
I have never used an SQL Agent job. Easy to setup?
I have never used an SQL Agent job. Easy to setup?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks to all...
ASKER