1 DECLARE @Name NVARCHAR (50) 2 SET @Name = ‘\EXAM\061023478874‘ 3 4 DECLARE @Position INT 5 6 --sql first indexof 7 SET @Position = CHARINDEX(‘.‘, @Name); 8 SELECT SUBSTRING (@Name, @Position+1,LEN(@Name)-@Position) 9 10 --sql last indexof 11 SET @Position = LEN(@Name) - CHARINDEX(‘\‘, REVERSE(@Name)) + 1 12 SELECT SUBSTRING (@Name, @Position+1,LEN(@Name)-@Position)
时间: 2024-09-29 22:12:02