Jamie said:
...or the OP could use a Jet 4.0 CHECK constraint that parsed out the
characters, used each character's ascii code to construct a key for
each row and test there are no duplicates.
Assuming the column is three ascii characters, the following Jet 4.0
CHECK constraint will have the effect of a case sensitive unique
constraint:
CREATE TABLE Test3 (
data_col CHAR(3) NOT NULL)
;
ALTER TABLE Test3 ADD
CONSTRAINT test3__case_sensitive_unique
CHECK (
NOT EXISTS
(
SELECT
FORMAT$(ASC(MID$(T1.data_col, 1, 1)), '0000')
& FORMAT$(ASC(MID$(T1.data_col, 2, 1)), '0000')
& FORMAT$(ASC(MID$(T1.data_col, 3, 1)), '0000'),
COUNT(*)
FROM Test3 AS T1
GROUP BY
FORMAT$(ASC(MID$(T1.data_col, 1, 1)), '0000')
& FORMAT$(ASC(MID$(T1.data_col, 2, 1)), '0000')
& FORMAT$(ASC(MID$(T1.data_col, 3, 1)), '0000')
HAVING COUNT(*) > 1
)
);
INSERT INTO Test3 (data_col) VALUES ('Abc')
;
INSERT INTO Test3 (data_col) VALUES ('ABc')
;
INSERT INTO Test3 (data_col) VALUES ('xYz')
;
INSERT INTO Test3 (data_col) VALUES ('xYz')
;
The CHECK only bites for the last insert i.e. does a case sensitive
comparison.
Jamie.
--