I want to create a rule to restrict special characters to be entered into a column. I have tried the following. But it didnt work.
CREATE RULE rule_spchar
AS
@ma
Your can create a Check Constraint
on this column and only allow Numbers
and Alphabets
to be inserted in this column, see below:
ALTER TABLE Table_Name
ADD CONSTRAINT ck_No_Special_Characters
CHECK (Column_Name NOT LIKE '%[^A-Z0-9]%')
ALTER TABLE Table_Name
ADD CONSTRAINT ck_Only_Numbers
CHECK (Column_Name NOT LIKE '%[^0-9]%')
ALTER TABLE Table_Name
ADD CONSTRAINT ck_Only_Alphabets
CHECK (Column_Name NOT LIKE '%[^A-Z]%')