我有一个有4列的表:
create table dbo.Table ( Id int not null,A int null,B int null,C nvarchar (4000) null )
如何确保A,B和C都是三个空或全部三个不为空?
解决方法
你可以设置一个
check constraint
:
constraint [check_abc] check ( ([A] is null and [B] is null and [C] is null) or ([A] is not null and [B] is not null and [C] is not null) )