Hello readers, Here are going to create a Check Constraint in SQL Server to allow only Alphabets in Column.

Check Constraint in SQL Server to  in the column:

Sometimes you face a situation to allow alphabets in columns. This is the real-world scenario.  Here I am going to create a Check Constraint that will prevent any character other than Alphabets.

Example:

Create Table:

CREATE TABLE EmployeeDetails
(ID INT, EmployeeName VARCHAR(100),
CONSTRAINT chkEmployeeName CHECK (EmployeeName NOT LIKE '%[^A-Z]%'))
GO

In the above script, i have created a Check Constraint called chkEmployeeName that will check if EmployeeName is not an Alphabet.

Test Check Constraint:

INSERT INTO [dbo].[EmployeeDetails] (ID, EmployeeName)
VALUES (1, 'DebugOnWeb')
GO

If you run the above run the above query it will run without any error, Now run the following query.

INSERT INTO [dbo].[EmployeeDetails] (ID, EmployeeName)
VALUES (1, 'DebugOnWeb 1')
GO

If you run the above following error will be raised.

Allow only Alphabets

So this simple Constraint solve the problem of allowing Alphabets in column

View More:

Conclusion:

I hope this Check Constrain of allowing only Alphabets in the column will solve your real-world problems. I would like to have your feedback, comments, and suggestions.

Thank You.

6 Comments

  • Throughout this great pattern of things you actually secure an A just for hard work. Where exactly you lost me personally was on your facts. You know, it is said, the devil is in the details… And that couldn’t be more correct at this point. Having said that, let me inform you what did work. Your text is certainly very engaging and that is possibly the reason why I am making the effort in order to comment. I do not really make it a regular habit of doing that. 2nd, despite the fact that I can notice a leaps in logic you come up with, I am not really certain of how you appear to connect the ideas that make your conclusion. For right now I will yield to your issue however trust in the future you link your facts better.

  • What’s up to every , since I am truly keen of reading this blog’s post to be updated daily. It consists of good material.|

  • Hello, its pleasant paragraph regarding media print, we all be aware of media is a impressive source of information.|

  • Aw, this was a very nice post. In idea I wish to put in writing like this moreover – taking time and precise effort to make an excellent article… but what can I say… I procrastinate alot and not at all appear to get something done.