select bmuid from areamaster
返回
AU15BA-001
AU15BLA-03
AU15B-02
我希望数据介于' 5'和' - ',像
BA
BLA
B
我的尝试
select @string=substring(BMUID,CHARINDEX('5',BMUID)+1,CHARINDEX('-',bmuid)) from BLOCKMASTER
答案 0 :(得分:0)
试试这个:
declare @text varchar(1000)
set @text ='AU15BA-001' // put your test AU15BA-001, AU15BLA-03, AU15B-02
declare @start varchar(100)
set @start = '5'
declare @end varchar(100)
set @end = '-'
select @text text_to_search
, substring( LEFT(@text, charindex(@end, @text)-1), CHARINDEX(@start, @text) + len(@start), LEN(@text)) result