34,575
社区成员
发帖
与我相关
我的任务
分享
select left([A_a],charindex(['D/',A_a])-1) from a
create table [a](a_a varchar(10))
insert into [a] values('100D/36F')
go
select left(a_a , charindex('D/',a_a) - 1) from a
drop table [a]
/*
----------
100
(所影响的行数为 1 行)
*/
if object_id('[A]') is not null drop table [A]
go
create table [A]([A_a] varchar(13))
insert [A]
select 'fdsaf/Dfdsfsd' union all
select 'fdasfd/D12'
select substring(A_a,1,charindex('/D',A_a)-1) from A
/*
fdsaf
fdasfd
*/
select left([A_a],charindex([A_a],'/')-1) from a