select substring(zd,charindex('[',zd)+1,charindex(']',zd)-charindex('[',zd)-1) from tb
create table tb(zd varchar(20)) insert into tb select '123[difs]' go select substring(zd,charindex('[',zd)+1,charindex(']',zd)-charindex('[',zd)-1) from tb /* -------------------- difs(1 行受影响)*/ go drop table tb
select substring(zd,charindex('[',zd)+1,charindex(']',zd)-charindex('[',zd)-1) from tb
from tb
insert into tb select '123[difs]'
go
select substring(zd,charindex('[',zd)+1,charindex(']',zd)-charindex('[',zd)-1)
from tb
/*
--------------------
difs(1 行受影响)*/
go
drop table tb
Set @Str = '123[difs]'Select SubString(@Str,CHARINDEX('[',@Str,0)+1, CHARINDEX(']',@Str,0)- CHARINDEX('[',@Str,0) -1 )