Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Replace 删除sql server中字符串中的空逗号_Replace - Fatal编程技术网

Replace 删除sql server中字符串中的空逗号

Replace 删除sql server中字符串中的空逗号,replace,Replace,我想删除下表中的空值逗号(第一个、最后一个和连续的空逗号)。我的表包含以下值 x --- ,1,2,3, 4,5,6 7,8,,,9 ,10,11 我想要下面的结果 O/P --- 1,2,3 4,5,6 7,8,9 10,11 CREATE TYPE TableVariable AS TABLE ( id int identity(1,1), field_ids INT, value VARCHAR(MAX) ) inse

我想删除下表中的空值逗号(第一个、最后一个和连续的空逗号)。我的表包含以下值

  x
 ---    
 ,1,2,3,
 4,5,6
 7,8,,,9
 ,10,11
我想要下面的结果

O/P
---
1,2,3
4,5,6
7,8,9
10,11

CREATE TYPE TableVariable AS TABLE
(
    id int identity(1,1),
    field_ids        INT,
    value    VARCHAR(MAX)
)

inserting values in this type

DECLARE @DepartmentTVP AS TableVariable;
insert into  @DepartmentTVP values(1994,',85574,,,85538,')

when i select from this type i want to remove this commas(first,last and consecutive commas in the value)

您的桌子设计超出最佳范围。最好的解决方案是完全删除CSV数据。您看到了维护此类数据的麻烦。这不是实际的表值。此类值从前端传递到存储过程。我想删除此空白值逗号。堆栈溢出不是免费的代码编写服务,请显示您的代码/工作以及实际问题是什么。请查看上面的帖子。我添加了我的需求。创建了用户定义的类型并将值插入到该类型中。当我从该类型中选择值时。我希望删除逗号。我希望这将适用于我的需求。创建表格xyz(x varchar(max))插入xyz值('1,2,3')插入xyz值('4,5,6'))插入xyz值('7,8,9')插入xyz值('10,11,12'))插入xyz值('13,14,15'))从xyz中选择替换(替换(LTRIM(替换(x,',','),,,,,,,,,,,,,,,'))