复制代码 代码如下:
—去除字符串中重復的值函數
create function StringRemove(@str nvarchar(2000))
returns varchar(2000)
as
begin
declare @result nvarchar(2000),@temp nvarchar(1000)
set @result=”
set @temp=”
while(charindex(‘,’,@str)<>0)
begin
set @temp=substring(@str,1,charindex(‘,’,@str))
if(charindex(@temp,@result)<=0)
set @result=@result+@temp
set @str=stuff(@str,1,charindex(‘,’,@str),”)
end
return @result
end
GO
–(‘塗聚文’,’塗’,’塗聚文’,’1′,’23’,’1′)
–測試
select dbo.StringRemove(‘塗聚文,塗,塗聚文,1,23,1’)
原创文章,作者:1402239773,如若转载,请注明出处:https://blog.ytso.com/234369.html