Reputation: 73
I want to have a check constraint that only allows inserts of alphabetic chars like: 'A' 'Marie', not allowing something like '1' '*#€*a'.
At the moment o have this expression:
CONSTRAINT CK_Pn CHECK (Name LIKE '%[^A-Za-z]%'
Upvotes: 0
Views: 277
Reputation: 1270723
You can use not like
:
CONSTRAINT CK_Pn CHECK (Name NOT LIKE '%[^A-Za-z]%'))
That is, Name
has no characters that are not alphabetic characters.
Upvotes: 1