declare @t table (dwgmc varchar(48))
insert into @t
select '011-钢梯T6-091(0600-8022-501)[td-tl]{asdfsdf}' union all
select '011-钢梯T6-091(0600-8022-505)[td-tl213]{asdfsdf}' union all
select '011-钢梯T6-091[td-tl1231]{asdfsdf}' union all
select '011-钢梯T6-091(0600-8022-501)[td-tl123]{asdfsdf}'
select
case when charindex('(',dwgmc)>0 and
charindex(')',dwgmc)>0
then
substring(dwgmc,charindex('(',dwgmc)+1,charindex(')',dwgmc)-charindex('(',dwgmc)-1)
else '无' end as dwgmc
from @t
/*
dwgmc
------------------------------------------------
0600-8022-501
0600-8022-505
无
0600-8022-501
*/
我就是执行了select case when charindex('(',dwgmc)>0 and charindex(')',dwgmc)>0 then substring(dwgmc,charindex('(',dwgmc)+1,charindex(')',dwgmc)-charindex('(',dwgmc)-1) else '无' end as dwgmc from entity_index 这句话报的错误!该怎么改? ------其他解决方案--------------------
没有反的也没有其他的( ------其他解决方案--------------------
select
case when charindex('(',dwgmc)>0 and charindex(')',dwgmc)>0 and charindex('(',dwgmc)<charindex(')',dwgmc)
then
substring(dwgmc,charindex('(',dwgmc)+1,charindex(')',dwgmc)-charindex('(',dwgmc)-1)
else '无' end as dwgmc
from entity_index