Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check constraint question
Message
De
03/08/1999 14:43:23
 
 
À
03/08/1999 12:33:52
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
00249280
Message ID:
00249362
Vues:
29
Ken,

>How can I set a check constraint to make sure the value is alphanumeric? that is - contains nothin but 0-9 and a-z anywhere in it?

Will something like this work?

ALTER TABLE tablename
ADD
CONSTAINT alphanum_only CHECK (vcolumn LIKE REPLICATE('[0-9A-Z]', DATALENGTH(v))

This seems to work best for varchar columns.

>Also - in a three tier (virtual 3-T at least), is this kind of validation best handled by back end or middle tier? It seems to fall somehwere in-between RI and business rule.

You could start a war with a question like this (bg). There are those people who believe that all rules should be handled by the middle tier. Then there are those people who believe that the rule should be handled at the lowest level (with the data layer being the lowest and the presentation layer the highest) that can implement it. There's probably not a right answer.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform