标签:max function article returns ret return sof var turn
--创建函数(此函数来自csdn,作者不详)
create function [dbo].[m_distinctStr](@s varchar(max))
returns varchar(100)
as
begin
if @s is null return(null)
declare @new varchar(50),@index int,@temp varchar(50)
while len(@s)>0
begin
set @new=isnull(@new,‘‘)+left(@s,1)
set @s=replace(@s,left(@s,1),‘‘)
end
return @new
end
--测试示例
select dbo.[m_distinctStr](‘Chinese‘) as str1
select dbo.[m_distinctStr](‘张三李四李四张三刘六‘) as str2
--运行结果结果
/*
str1
---------
Chines
str2
------------
张三李四刘六
*/
标签:max function article returns ret return sof var turn
原文地址:http://www.cnblogs.com/accumulater/p/6244604.html