I'm trying to create a constraint for a SQL Server table in order to allow only 3 letters and 4 numbers on a single varchar(7)
column.
Example: ABC1234
Can anyone help?
You could use:
ALTER TABLE tab_name ADD CONSTRAINT
constraint_name CHECK (col LIKE '[A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9]');
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.