I have one column called Name and in the column I have values
Name
001 BASI Distributor (EXAM)
002 BASI Supplier (EXAM2)
MASI DISTRIBUTOR (EXAM002)
MASI SUPPLIER (EXAM003)
EXAM_ND Distributor Success System Test (EXAM_ND)
EXAM_SS Supplier Success System Test (EXAM_SS)
now I want to separate the value inside the ()
from this whole string.How I will get this I tried for the SUBSTRING (Name ,22 ,4 )
but this will help for single one I want to get the result using some unique solution.
SELECT SUBSTRING(Name,
CHARINDEX('(', Name) + 1,
CHARINDEX(')', Name) - CHARINDEX('(', Name) - 1)
Try this one -
DECLARE @temp TABLE (st NVARCHAR(50))
INSERT INTO @temp (st)
VALUES
('001 BASI Distributor (EXAM)'),
('002 BASI Supplier (EXAM2)'),
('MASI DISTRIBUTOR (EXAM002)'),
('MASI SUPPLIER (EXAM003)'),
('EXAM_ND Distributor Success System Test (EXAM_ND)'),
('EXAM_SS Supplier Success System Test (EXAM_SS)')
SELECT SUBSTRING(
st,
CHARINDEX('(', st) + 1,
CHARINDEX(')', st) - CHARINDEX('(', st) - 1
)
FROM @temp
Output -
-------------
EXAM
EXAM2
EXAM002
EXAM003
EXAM_ND
EXAM_SS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With