Guys,
Does SQL Server allow for creating conditional constraints on the table columns?
My table is:
CREATE TABLE [X]
(
[UID] [int] IDENTITY (1, 1) NOT NULL ,
[A] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL ,
[b] [bit] NOT NULL ,
CONSTRAINT [PK_X] PRIMARY KEY CLUSTERED
(
[UID]
) ON [PRIMARY]
) ON [PRIMARY]
I want to add the following constraints:
CONSTRAINT [IX_UNIQUE1] UNIQUE NONCLUSTERED
(
A, B = 1
) ON [PRIMARY]
CONSTRAINT [IX_UNIQUE2] UNIQUE NONCLUSTERED
(
UPPER(A), B = 0
) ON [PRIMARY]
That is, if the table contains "Hello" in column A, then an insert of ("hello", 1) will be rejected, but ("hello", 0) will be inserted.
Any ideas?
Thanks a lot