Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Allow only alphabets in column in SQL Server

  • Last Updated : 30 Aug, 2021

There may occur some situations when data in column should only be in alphabets, for example: Name column in details table. If user try to input other than alphabets, it will give error. To allow only alphabets in a column check constraint can be applied over column. 
To get information about Constraints and Check Constraints, refer below article links: 
 

Syntax: 
 

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

CONSTRAINT (Constraint_Name) 
CHECK ( BOOLEAN EXPRESSION)

Example 1: In this example, constraints are applied on ADDRESS column to check if value inserted in ADDRESS column consist of only alphabets or not. The value inserted in ADDRESS column consists of only alphabets and thus it works fine and does not show any error. The condition NOT LIKE %[^A-Z]% checks is input values are alphabets or not. 
 



Output: 
 

Example 2: In this example, constraints are applied on ADDRESS column to check if entered value consist of only alphabets or not. The value inserted in ADDRESS column consists of alphabets and integer and thus it shows error. The ADDRESS “GEEKS1” is responsible for error. 
 

Output: 
 

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :