CREATE FUNCTION dbo.fnGetForeignerShotName ( @str NVARCHAR(4000) )
RETURNS NVARCHAR(2000)
AS
BEGIN
DECLARE @retval NVARCHAR(2000);
SET @str=RTRIM(LTRIM(@str));
SET @retval=''
WHILE CHARINDEX(' ',@str,1)>0 BEGIN
SET @retval+=LEFT(@str,1)+'* ';
SET @str= LTRIM(RIGHT(@str,LEN(@str)-CHARINDEX(' ',@str,1)));
END
set @retval+=@str;
RETURN @retval;
END
GO
SELECT dbo.fnGetForeignerShotName('Michael Joseph Jackson');
来源:oschina
链接:https://my.oschina.net/bigball/blog/4912725