56,679
社区成员
发帖
与我相关
我的任务
分享
CREATE function GetCharIndexNum (`@findstring` varchar(255),`@string` varchar(255))
returns int
BEGIN
declare `@location` int ;
declare `@num` int ;
set @num =0;
set @location = charindex (@findstring,@string);
while @location >0 do
begin
set @num =@num +1;
set @string =substring(@string,@location+1,len(@string));
set @location = charindex (@findstring,@string);
end
return @num
END
CREATE FUNCTION `GetCharIndexNum`(`findstring` VARCHAR(255),
`string` VARCHAR(255))
RETURNS INT
NO SQL
DETERMINISTIC
BEGIN
DECLARE `location` INT;
DECLARE `num` INT;
SET num =0;
SET location = charindex (findstring, string);
WHILE location > 0 DO
SET num = num +1;
SET string = Substring(string, location+1, len(string));
SET location = Charindex (findstring, string);
END WHILE;
RETURN num;
END;