您的位置:首页 > 数据库

[收集]自己编写一个SQL Server中用的lastindexof函数

2008-03-20 12:06 330 查看
CREATE FUNCTION dbo.lastindexof (@stringValue as nvarchar(1000), @stringSearch as nvarchar(1000), @startPosition as int = 0)
returns int
AS
BEGIN
DECLARE @lastindex int
SET @lastindex= @startPosition
DECLARE @tempindex int
while (1=1)
begin
SET @tempindex = charindex(@stringSearch, @stringValue, @lastindex + 1)
if (@tempindex = 0)
break
SET @lastindex = @tempindex
end
RETURN(@lastindex)
END
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: