我有一个长的字符串,字符串中有多个括号,我试图仅提取字符串的最后一部分,但是我已经达到了第一部分直到结尾。
Alkyl acrylate-Styrene (or alpha-Methylstyrene) copolymer (Substances not
requiring notification is limited to the following: Copolymer of butyl
acrylate / styrene (It is limited that the polymer is insoluble in water, acid
and alkali, and the content of the components having molecular weight less
than 1,000 is 1% or less.))
我的查询:
SELECT [RigNumSrc],[SubSRC],
case when CHARINDEX(' (',[SubSRC])<>0 then LEFT ([SubSRC], charindex (' (',
[SubSRC])-1)
when CHARINDEX(' (',[SubSRC])=0 then [SubSRC] end as [chemnamesrc1]
,case when CHARINDEX(' (',[SubSRC])<>0 then SUBSTRING([SubSRC],
CHARINDEX('
(',[SubSRC]),LEN([SubSRC]))
end as synamesrc1 from xyztable
我的结果:
(or alpha-Methylstyrene) copolymer (Substances not requiring notification
is limited to the following: Copolymer of butyl acrylate / styrene (It is
limited that the polymer is insoluble in water, acid and alkali, and the
content of the components having molecular weight less than 1,000 is 1%
or less.))
请只帮助我查找:
(It is limited that the polymer is insoluble in water, acid
and alkali, and the content of the components having molecular weight less
than 1,000 is 1% or less.)
尝试:
DECLARE @myString VARCHAR(MAX)='Alkyl acrylate-Styrene (or alpha-Methylstyrene) copolymer (Substances not requiring notification is limited to the following: Copolymer of butyl
acrylate ( styrene (It is limited that the polymer is insoluble in water, acid and alkali, and the content of the components having molecular weight less than 1,000 is 1% or less.))'
SELECT CASE WHEN RIGHT(@myString,1) <> ')' THEN NULL ELSE REPLACE(RIGHT(@myString , CHARINDEX ('(' ,REVERSE(@myString))),'))',')') END
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句