declare @SubTeamId varchar(100)
set @SubTeamId='T001/T006/T100/T123/'
--select len(@SubTeamId) --结果为19
--SELECT substring(@SubTeamId,0,charindex('/',@SubTeamId)) --结果为T001
--select right(@SubTeamId,len(@SubTeamId)-charindex('/',@SubTeamId)) --结果为T006/T100/T123/
while(charindex('/',@SubTeamId)>0)
begin
select substring(@SubTeamId,0,charindex('/',@SubTeamId))
set @SubTeamId=right(@SubTeamId,len(@SubTeamId)-charindex('/',@SubTeamId))
end
set @SubTeamId='T001/T006/T100/T123/'
--select len(@SubTeamId) --结果为19
--SELECT substring(@SubTeamId,0,charindex('/',@SubTeamId)) --结果为T001
--select right(@SubTeamId,len(@SubTeamId)-charindex('/',@SubTeamId)) --结果为T006/T100/T123/
while(charindex('/',@SubTeamId)>0)
begin
select substring(@SubTeamId,0,charindex('/',@SubTeamId))
set @SubTeamId=right(@SubTeamId,len(@SubTeamId)-charindex('/',@SubTeamId))
end