i have a table like this
tab1
create table tab1(ID int identity(1,1), Type varchar(10),IsValued bit)
标签1:
ID Type IsValued
----------------
1 S 1
2 R 0
3 R 0
4 S 1
5 S 1
6 R 0
7 S 1
我希望创建一个约束(非触发器),而不是将值插入到IsValued列中。 当Type ='S'时,应将IsValued插入为1,当Type ='R'时,应将IsValued插入为0。
例如:IsValued = case when Type ='S' then 1 when Type ='R' then 0 end
我该如何实现这个约束?