Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check constraint question
Message
From
03/08/1999 14:43:23
 
 
To
03/08/1999 12:33:52
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
00249280
Message ID:
00249362
Views:
23
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform