SQL集锦之IndexOf、LastIndexOf 【转】
DECLARE @Name NVARCHAR (50)
SET @Name = '12345.67890ABCDE.FGHIJKLMNOPQRSTUVWXYZTest'
DECLARE @Position INT
--sql first indexof
SET @Position = CHARINDEX('.', @Name);
SELECT SUBSTRING (@Name, @Position+1,LEN(@Name)-@Position)
--sql last indexof
SET @Position = LEN(@Name) - CHARINDEX('.', REVERSE(@Name)) + 1
SELECT SUBSTRING (@Name, @Position+1,LEN(@Name)-@Position)
摘自:http://blog.sina.com.cn/s/blog_71f2bd7f0100ultn.html