从其他位列计算位列的公式是什么?
例如:
CREATE TABLE #Employee
(
[empNumb] [INT] identity(1,1) PRIMARY KEY,
[IsOk] [BIT] NOT NULL, -- This is computed from other three columns.
[HasValidHours] [BIT] NOT NULL,
[NoDemerits] [BIT] NOT NULL,
[NoAccidents] [BIT] NOT NULL
);
ALTER TABLE #Employee ADD CONSTRAINT [DF_Employee_HasValidHours]
DEFAULT ((0)) FOR [HasValidHours];
ALTER TABLE #Employee ADD CONSTRAINT [DF_Employee_NoDemerits]
DEFAULT ((0)) FOR [NoDemerits];
ALTER TABLE #Employee ADD CONSTRAINT [DF_Employee_NoAccidents]
DEFAULT ((0)) FOR [NoAccidents];
IsOk
将根据 ,和的and -ing计算。HasValidHours
NoDemerits
NoAccidents
如果其他三位列都 = 1,否则 IsOk = 0,您的意思是 IsOk = 1?
如果是这样: -
请参见&(按位与)(Transact-SQL)
您正在寻找的表达式是(无论您是执行计算列还是外部
UPDATE
):