从sqlserver中的数据单元中删除重复的逗号分隔值 [英] Removing duplicate comma seperated values from a datacell in sqlserver

查看:106
本文介绍了从sqlserver中的数据单元中删除重复的逗号分隔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我有一张表,其中的一列具有逗号分隔的值,该值可能是重复的.我想从此表中选择数据时从列中删除所有重复项,因为我需要从选定表中填充的数据表中将相同数据导出到excel中.

请帮忙.

有关更多信息,请随时询问.

谢谢

Varun Sareen

Dear Friends,

I have a table in which one of the columns is having comma separated values which may be duplicate. I want to remove all the duplicate items from the column while selecting the data from this table as i required to export the same data into excel from the datatable filled from the selected table.

Please help.

For more clarity on this please don''t hesitate to ask.

Thanks

Varun Sareen

推荐答案

如果可以访问单元格中的数据,则可以使用RegEx轻松替换重复的内容.
尝试 str = Regex.Replace(cellContent,@(\ b \ w + \ b)\ s +(\ 1(\ s + |
IF you can access data in the cell, you can replace the duplicate content very easily by using RegEx.
Try str = Regex.Replace(cellContent, @"(\b\w+\b)\s+(\1(\s+|


)))+ ,"


1); .
1 ");.


这篇关于从sqlserver中的数据单元中删除重复的逗号分隔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆