27,579
社区成员
发帖
与我相关
我的任务
分享
create table tb(规格型号 nvarchar(20))
insert into tb select 'Y-80M1-2/0.75'
insert into tb select 'Y-80M2-2/1.1'
insert into tb select 'Y-90S-2/1.5'
insert into tb select 'Y-90L-2/2.2'
insert into tb select 'Y-100L-2/3'
insert into tb select 'Y-112M-2/4'
insert into tb select 'Y-132S1-2/5.5'
insert into tb select 'Y-132S1-2/5.5'
insert into tb select 'Y-132S2-2/7.5'
insert into tb select 'Y-132S2-2/7.5'
insert into tb select 'Y-160M1-2/11'
insert into tb select 'Y-160M1-2/11'
insert into tb select 'Y-160M2-2/15'
insert into tb select 'Y-160M2-2/15'
insert into tb select 'Y-160L-2/18.5'
insert into tb select 'Y-160L-2/18.5'
insert into tb select 'Y-180M-2/22'
insert into tb select 'Y-180M-2/22'
insert into tb select 'Y-200L1-2/30'
insert into tb select 'Y-200L1-2/30'
insert into tb select 'Y-200L2-2/37'
insert into tb select 'Y-200L2-2/37'
insert into tb select 'Y-200L2-2/37'
insert into tb select 'Y-225M-2/45'
insert into tb select 'Y-225M-2/45'
insert into tb select 'Y-225M-2/45'
insert into tb select 'Y-250M-2/55'
insert into tb select 'Y-280S-2/75'
insert into tb select 'Y-280M-2/90'
insert into tb select 'Y-280M-2/90'
go
select left(规格型号,charindex('-',规格型号,charindex('-',规格型号)+1)-1) from tb
go
drop table tb
/*
--------------------
Y-80M1
Y-80M2
Y-90S
Y-90L
Y-100L
Y-112M
Y-132S1
Y-132S1
Y-132S2
Y-132S2
Y-160M1
Y-160M1
Y-160M2
Y-160M2
Y-160L
Y-160L
Y-180M
Y-180M
Y-200L1
Y-200L1
Y-200L2
Y-200L2
Y-200L2
Y-225M
Y-225M
Y-225M
Y-250M
Y-280S
Y-280M
Y-280M
(30 行受影响)
*/
select
case when
charindex('-',Gauge,charindex('-',Gauge)+1)=0
then
Gauge
else
left(Gauge,charindex('-',Gauge,charindex('-',Gauge)+1)-1)
end
from
tb
create table tb(Gauge varchar(20))
insert into tb select 'Y-80M1-2/0.75'
insert into tb select 'Y-80M2-2/1.1'
insert into tb select 'Y-90S-2/1.5'
insert into tb select 'Y-90L-2/2.2'
insert into tb select 'Y-100L-2/3'
insert into tb select 'Y-112M-2/4'
insert into tb select 'Y-132S1-2/5.5'
insert into tb select 'Y-132S1-2/5.5'
insert into tb select 'Y-132S2-2/7.5'
insert into tb select 'Y-132S2-2/7.5'
insert into tb select 'Y-160M1-2/11'
insert into tb select 'B-0.64mm'
insert into tb select 'B-0.80mm'
insert into tb select 'YEJ2-80'
insert into tb select 'B-0.55mm'
insert into tb select 'B-0.41mm'
insert into tb select 'B-0.63mm'
insert into tb select 'M8*20'
insert into tb select 'M16*160'
select Case When charindex('-',Gauge,charindex('-',Gauge)+1)=0 then Gauge
Else left(Gauge,charindex('-',Gauge,charindex('-',Gauge)+1)-1)
end
from tb