Check 约束
Alter table Employee
Add
Constraint che_Age
Check (datediff(year,getdate(),Birthday)>18 and (datediff(year,getdate(),Birthday)) <45)
Go
Insert into Employee(eName,Sex,Birthday,Phone,ePost,brNo)
Values('张丹','女',1988-6-9,13456789343,'职员',01)
-------------------------------------------------------------------
消息 547,级别 16,状态 0,第 1 行
INSERT 语句与 CHECK 约束"che_Age"冲突。该冲突发生于数据库"MySample",表"dbo.Employee", column 'Birthday'。
语句已终止。
求解!