I have a unique constraint on a SQL server 2008 database table, with the constraint containing 4 columns. While entering in some test data, I unexpectedly received a unique constraint violation. For the four columns I was just entering in a number, inserting the value set, incrementing the number, then repeating (i.e. (1,1,1,1) (2,2,2,2,)... etc.). The violation occurred when I got to 10. If I enter any number now, it will violate the constraint. I then tried it entering just the letter 'A', and tried to insert any words beginning with 'A', which led to a violation. Do I need to change something in my constraint, or this how they are actually supposed to work?
ALTER TABLE [dbo].[Table] ADD CONSTRAINT [UC_Table_Column1_Column2_Column3_Column4]
UNIQUE NONCLUSTERED
(
[Column1] ASC,
[Column2] ASC,
[Column3] ASC,
[Column4] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF,
IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON
[PRIMARY]