-- Q : Extract text in between the parentheses i.e, ()
---- CONTACT table with ID , Name
CREATE TABLE #Contact
(
ID INT,
Name VARCHAR(30)
);
-- INSERT VALUES INTO THE #Contact Table
INSERT INTO #Contact VALUES(1,'(Harsha) Vardhan');
INSERT INTO #Contact VALUES(4,'(Adora) Khan');
INSERT INTO #Contact VALUES(2,'(Rohan) Swarndeep');
INSERT INTO #Contact VALUES(5,'(Earlene) Bist');
INSERT INTO #Contact VALUES(3,'(Neil) Acharya');
--- RUN THE FOLLOWING QUERY
-- With Brackets
SELECT Name , SUBSTRING( Name, CHARINDEX('(',Name) , CHARINDEX(')',Name)) As With_Brackets
FROM #Contact;
-- Without Brackets
SELECT Name , SUBSTRING( Name, CHARINDEX('(',Name)+1 , CHARINDEX(')',Name)-2) AsWithout_Brackets
FROM #Contact;
-- Linkedin Profile : https://www.linkedin.com/in/harshasannareddy/