费话不多说直接上代码:
declare @str varchar(50) set @str='ab-cd-ef-gh' select reverse(substring(reverse(@str),1,charindex('-',reverse(@str)))) declare @s varchar(100); set @s = 'ab-cd-ef-gh'; select substring(@s,len(@s)-charindex('-',reverse(@s))+2,8000)