I have a table similar to the following:-
CREATE TABLE [dbo].[child_table]( child_id [int] IDENTITY(1,1) NOT NULL, child_status [varchar](25) NULL, parent_id [int] NOT NULL, CONSTRAINT [PK__child_table] PRIMARY KEY CLUSTERED ( child_id ASC ) )
Each parent_id may have one or more child_id's. But only one child (of each parent) may have a "child_status" of "Active". Is there a way to enforce this in TSQL (e.g. with a CHECK CONSTRAINT or RULE), I can't find a way to do this.
Thanks