Sql server SQL:我想删除重复的字符串
如何查找和删除重复项 例如:Sql server SQL:我想删除重复的字符串,sql-server,replace,duplicates,Sql Server,Replace,Duplicates,如何查找和删除重复项 例如: Rest of the World. Rest of the World AFC Cup 结果: AFC Cup 我试过这个: DECLARE @STR VARCHAR (20) SET @STR = 'Rest of the World. Rest of the World. AFC Cup ' SELECT LEN (@STR) - LEN (@STR, 'Rest of the World', '') 但这是错误的答案 选择值 SELECT val
Rest of the World. Rest of the World AFC Cup
结果:
AFC Cup
我试过这个:
DECLARE @STR VARCHAR (20)
SET @STR = 'Rest of the World. Rest of the World. AFC Cup '
SELECT LEN (@STR) - LEN (@STR, 'Rest of the World', '')
但这是错误的答案 选择值
SELECT value
FROM STRING_SPLIT(@tags, ' ')
WHERE RTRIM(value) <> ''
GROUP BY value
HAVING COUNT(VALUE) = 1
从字符串分割(@tags,“”)
其中RTRIM(值)'
按值分组
有计数(值)=1
这将返回不同行中的单个单词。使用光标并在列表上迭代并加入单词。我建议将
字符串\u AGG
放在光标上。在DBMS中,迭代很少像数据集方法那样快。