Write following code to create table and apply regular expression validation on it.
-- Create StudentTable
CREATE TABLE StudentTable
(ID INT, Name VARCHAR(100),
CONSTRAINT Name CHECK (Name NOT LIKE '%[^A-Z]%'))
GO
-- This will be successful
INSERT INTO StudentTable (ID, Name)
VALUES (1, 'Manish')
GO
-- This will throw an error
INSERT INTO StudentTable (ID, Name)
VALUES (1, 'Manish cho 1')
GOWe can change the above regular expression depend on our need to apply any kind of validation.