Allow Only Alphabets in Column- in sql server

Write following code to create table and apply regular expression validation on it.

  1. -- Create StudentTable  
  2. CREATE TABLE StudentTable  
  3. (ID INT, Name VARCHAR(100),  
  4. CONSTRAINT Name CHECK (Name NOT LIKE '%[^A-Z]%'))  
  5. GO  
  6. -- This will be successful  
  7. INSERT INTO StudentTable (ID, Name)  
  8. VALUES (1, 'Manish')  
  9. GO  
  10. -- This will throw an error  
  11. INSERT INTO StudentTable (ID, Name)  
  12. VALUES (1, 'Manish cho 1')  
  13. GO 
We can change the above regular expression depend on our need to apply any kind of validation.