DECLARE @str AS VARCHAR(25)=‘123_234_567‘
select substring(@str,1,LEN(@str)-CHARINDEX(‘_‘,reverse(@str)))
输出 123_234
DECLARE @str AS VARCHAR(25)=‘123_234_567‘
select reverse(substring(reverse(@str),1,charindex(‘_‘,reverse(@str)) - 1))
输出567
时间: 2024-09-30 19:46:48