I have a table with a few columns that are used as datetime stamps. The table contains the following columns
UpDate datetime
SearchDate datetime
ExpDate dateadd(hour,24,UpDate)
Active nvarchar(5)
When the UpDate column is updated by the daily import the computed column ExpDate will be updated with the time + 24 hours. I would like the Active column to indicate 'Y' when the current datetime is less than the ExpDate and 'N' when the current datetime is equal to or more than the ExpDate.
I thought of just using a stored procedure to run indefinitely to check this and update as needed but that does not make sense to do and would like to know if anyone has any other suggestions on how to do this. For example if I can use that as a computed column as well based on an IF statement query.
Unless you have a good reason to persist the calculation of
ExpDateandActiveI think you should do the calculation in your queries against the your table.Something like this:
If you want computed columns your DDL would look like this: