Hey there, In SQL server 2000, I need to create a constraint on one of
the columns that the field enterd must be 2 alpha charactors and the
last 3 must be numeric.
soo, for example
aa123
thanx in advanceUse something like this:
ALTER TABLE TableName ADD CONSTRAINT ConstraintName
CHECK (ColumnName LIKE '[A-Z][A-Z][0-9][0-9][0-9]')
Razvan
Bonzol wrote:
> Hey there, In SQL server 2000, I need to create a constraint on one of
> the columns that the field enterd must be 2 alpha charactors and the
> last 3 must be numeric.
> soo, for example
> aa123
> thanx in advance|||Thanx, but where would I actually put this? atm im trying through right
clicking on the column and creatinng a constraint|||You can execute the above statement in a Management Studio query window
(or in Query Analyzer if you are using SQL Server 2000).
If you want to do this using the graphical interface (in Management
Studio), you should go to the Constraints node (not the Columns node),
right click and choose "New Constraint..."; in the "Expression", type:
ColumnName LIKE '[A-Z][A-Z][0-9][0-9][0-9]'
(of course, replace ColumnName with the name of your column)
Razvan
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment