CHECK constraint for allowing only alphabets

  • I am reading Joe celko's sql for smarties and in that he specifies a technique to check a column has only non-alphabets entered

    CREATE TABLE alpha(allalpha varchar(100) CHECK(UPPER(allalpha)=LOWER(allalpha)))

    but when I run this in sql server 2008 it allows all alphabets and non-alphabets. I know there is another method using LIKE predicate. But am I missing something or the code need any changes?

  • Isn't it a problem of case insensitive collation ?

  • Well the db is in CI collation. But now I changed the collation (Latin1_General_100_CS_AI) and checked but the same thing happened.

  • In a new database, with sensitive collation, the check constraint works fine.

    How did you change the collation ?

  • yup that worked , so this only works for a CS collation. Thanks helping Roland

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply