栏目分类:
子分类:
返回
终身学习网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
终身学习网 > IT > 系统运维 > 数据库 > MySQL > MsSql

sqlserver中去除字符串中连续的分隔符的sql语句

MsSql 更新时间:发布时间: 百科书网 趣学号
以下测试用于去除任何字符串中连线的分隔符
复制代码 代码如下:
--去除字符串中连续的分隔符
declare @str nvarchar(200)
declare @split nvarchar(200),@times int
set @str='中 国1 2 34 55 5 6 7 7';--字符
set @split=' '; --分隔符
select @times=(len(@str)-len(replace(@str,@split+@split,'')))/2
while @times>0
begin
set @str=REPLACE(@str,@split+@split,' ')
set @times=@times-1
end
select @str

希望对大家有作用

测试结果:

中 国1 2 34 55 5 6 7 7

(1 行受影响)
转载请注明:文章转载自 www.051e.com
本文地址:http://www.051e.com/it/170153.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 ©2023-2025 051e.com

ICP备案号:京ICP备12030808号