hi i want add constraint in sql server i try this but not work i needd check if a word 2 char and 3 numbers after example aa192:
create table test(
idtest int primary key ,
neEdition varchar(50)
);
alter table test add constraint ch_like check(neEdition like'[a-z][a-z][0-9][0-9][0-9]');
You code works in rextester .
Given what you are doing, I would recommend that the edition be declared to have 5 characters:
neEdition varchar(5)
or:
neEdition char(5)
That is more consistent with the check constraint.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.