Subject | Unique index that allows difference in trailing whitespace? |
---|---|
Author | Kjell Rilbe |
Post date | 2013-10-13T06:46Z |
Hi,
I have a table that contains a varchar and there is a unique constraint
on that varchar column.
My problem is that I would need the table to allow values that differ
(only) in trailing whitespace.
Due to the char/varchar legacy compatibility debacle (ugh!) that
dictates that varchar and char values that differ in trailing whitespace
should be considered equal, this is not allowed using a regular unique
constraint.
Is there any better way to solve this, than using a unique computed
index on the expression varcharcol || '.' or something similar?
(And, are there in fact, any major drawbacks with the computed unique
index solution?)
Regards,
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
I have a table that contains a varchar and there is a unique constraint
on that varchar column.
My problem is that I would need the table to allow values that differ
(only) in trailing whitespace.
Due to the char/varchar legacy compatibility debacle (ugh!) that
dictates that varchar and char values that differ in trailing whitespace
should be considered equal, this is not allowed using a regular unique
constraint.
Is there any better way to solve this, than using a unique computed
index on the expression varcharcol || '.' or something similar?
(And, are there in fact, any major drawbacks with the computed unique
index solution?)
Regards,
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64