我是靠谱客的博主 可爱月亮,这篇文章主要介绍sql函数实现去除字符串中的相同的字符串,现在分享给大家,希望可以做个参考。

复制代码 代码如下:

---去除字符串中重復的值函數
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')

最后

以上就是可爱月亮最近收集整理的关于sql函数实现去除字符串中的相同的字符串的全部内容,更多相关sql函数实现去除字符串中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(166)

评论列表共有 0 条评论

立即
投稿
返回
顶部