I want to know if it's possible to create a column in a table, that get's their value automatically based on the value of another column in the same table, example below to clarify:
CREATE TABLE dbo.example
(
m_id INT NOT NULL CONSTRAINT PK_mid PRIMARY KEY IDENTITY (1,1),
m_name NVARCHAR(30) NOT NULL,
m_startdate DATE NOT NULL CONSTRAINT CHK_startdate CHECK(m_startdate <= SYSDATETIME()),
m_enddate DATE CONSTRAINT CHK_enddate CHECK(m_enddate <= SYSDATETIME()),
m_status INT CONSTRAINT CHK_status CHECK(m_status = 0 or m_status = 1)
)
I want to make m_status receive 0 if m_enddate is null and 1 if it's not null. This of course would be upon an insert of a row.