【问题标题】:To remove the special character from the column using recursive CTE method [duplicate]使用递归 CTE 方法从列中删除特殊字符 [重复]
【发布时间】:2018-07-07 22:38:11
【问题描述】:

我有一张这样的桌子:

     |----------------------------|
     |  CardCorporateName         |
     |----------------------------|
     | ~$%/*dfgdggf/*(            |
     |---------------------       |
     | ^^&@~`58964sdhfdk-+*/-=-0  |
     |----------------------------|

我需要从 CardCorporateName 列中删除特殊字符,我的输出应该是这样的:

   |----------------------------|
   |  CardCorporateName         |
   |----------------------------|
   | dfgdggf                    |
   |----------------------------|
   | 58964sdhfdk                |
   |----------------------------|

有没有什么方法可以使用递归 CTE 方法从列中删除特殊字符?

【问题讨论】:

  • 是不是字母数字的特殊字符;还是有其他安全字符?
  • @JohnLBevan 它不应该是字母数字......就是这样。(需要避免不是字母数字的字符)
  • @DeadCat 如果您只想要字母数字,请查看链接帖子
  • @WhatsThePoint 但它使用通过函数..有没有使用递归 CTE 方法的方法? (问题已编辑)
  • @DeadCat 为什么你更喜欢递归 CTE 而不是函数?

标签: sql sql-server sql-server-2005 ssms


【解决方案1】:
SELECT REPLACE(REPLACE('~$%/*dfgdggf/*(', '~$%/*', ''),'/*(','')

SELECT REPLACE(REPLACE('^^&@~`58964sdhfdk-+*/-=-0','^^&@~`',''),'-+*/-=-0','')

【讨论】:

  • 请解释你的代码
猜你喜欢
  • 2021-07-27
  • 1970-01-01
  • 1970-01-01
  • 2014-05-20
  • 2020-11-19
  • 2022-07-19
  • 2014-05-14
  • 1970-01-01
  • 2012-12-16
相关资源
最近更新 更多