declare @t table(str varchar(20))
insert into @t select 'CM6W-15M±0.1%T'
insert into @t select 'CMD1/2W-20K±5%4'
insert into @t select 'FD1/4W-1K±1%36M'
insert into @t select 'FD3W-1M±10%1'
select
substring(str,case isnumeric(substring(str,3,1)) when 1 then 3 else 4 end,charindex('W',stuff(str,1,3,''))+3-case isnumeric(substring(str,3,1)) when 1 then 2 else 3 end)+','
+
substring(str,charindex('±',str),charindex('%',str)-charindex('±',str)+1)
as str
from @t
declare @t table(str varchar(20))
insert into @t select 'CM6W-15M±0.1%T'
insert into @t select 'CMD1/2W-20K±5%4'
insert into @t select 'FD1/4W-1K±1%36M'
insert into @t select 'FD3W-1M±10%1'
select
substring(str,case isnumeric(substring(str,3,1)) when 1 then 3 else 4 end,charindex('W',str)-case isnumeric(substring(str,3,1)) when 1 then 2 else 3 end)+','
+
substring(str,charindex('±',str),charindex('%',str)-charindex('±',str)+1)
as str
from @t
--这样?
declare @t table([str] varchar(20))
insert into @t select 'CM6W-15M±0.1%T'
union all select 'CMD1/2W-20K±5%4'
union all select 'FD1/4W-1K±1%36M'
union all select 'FD3W-1M±10%1'
union all select 'TE3W-31M±90%1'
select substring([str],patindex('%[0-9]%',[str]),charindex('-',[str])-patindex('%[0-9]%',[str]))+','+substring([str],charindex('±',[str]),charindex('%',[str])-charindex('±',[str])+1) from @t
--检查第三个是否字母是就取出到w为结尾的作为第一个字符串。第二个字符串取±之间部分%
--如果上面的定义就是楼主的意思。那么可以如下操作。
declare @t table(a varchar(20))
insert into @t
select 'CM6W-15M±0.1%T' union
select 'CMD1/2W-20K±5%4' union
select 'FD1/4W-1K±1%36M' union
select 'FD3W-1M±10%1'
select case isnumeric(substring(a,3,1)) when 1 then substring(a,3,charindex('w',a)-2)
else substring(a,4,charindex('w',a)-3) end,
substring(a,charindex('±',a),charindex('%',a)-charindex('±',a)+1)
from @t
/*
6W ±0.1%
1/2W ±5%
1/4W ±1%
3W ±10%