- hasSister BIT NOT NULL
- SisterName varchar(250) NULL
- SisterAge int NULL
Fill up SisterName if hasSister is true
ALTER TABLE TableName WITH CHECK ADD CONSTRAINT CK_TableName_SisterName CHECK ((hasSister=1 AND SisterName IS NOT NULL) OR (hasSister=0 AND SisterName IS NULL))Fill up SisterAge with positive int if hasSister is true
GO
ALTER TABLE TableName CHECK CONSTRAINT CK_TableName_SisterName
GO
ALTER TABLE TableName WITH CHECK ADD CONSTRAINT CK_TableName_SisterAge CHECK ((hasSister=1 AND SisterAge IS NOT NULL AND SisterAge > 0) OR (hasSister=0 AND SisterAge IS NULL))
GO
ALTER TABLE TableName CHECK CONSTRAINT CK_TableName_SisterAge
GO
No comments:
Post a Comment