I have a table (tblMessage) with columns (id, title, contents, publishingDateTime, status). The publishingDateTime column is the Date in which the message will publish. I want to change the value of column (status) automatically from (pending to published – OR – from false to true) when it is reached to its publishingDateTime.
How it is possible in Sql Server 2005?
Probably the easiest way is to not change the value at all. Instead, use a calculated column, with logic such as:
This goes in the
create tablestatement and is explained here.You can also do something similar by creating a view and doing all access to the table through a view (often a good idea anyway).
As an example, I the create table statement would look like:
For a view, you would do something like:
It is actually better practice not to use the
*in the view, but to list out all the columns.