C E C E - 5 months ago 6
SQL Question

Deny specific chars

I need to create a constraint or something similar, which only allows chars like

A-Z
,
_
and
-
in a column.

How can this be done?

Answer

try this..It Work Fine In ms sql server

CREATE TABLE TestTable
(ID INT, FirstCol VARCHAR(100),
CONSTRAINT FirstCol CHECK (FirstCol NOT LIKE '%[^a-zA-Z\_-]%' ESCAPE '\'))