【问题标题】:Replace some of string in SQL Server替换 SQL Server 中的一些字符串
【发布时间】:2014-07-27 19:03:40
【问题描述】:

我使用 SQL Server 2008 R2

由于在 SQL Server 中执行正则表达式并不容易,我需要一些关于如何解决此问题的建议。

我有一列包含以下类型的数据:

id   Ville
------------------
1    Saint azeraze
2    Saint ooiqsdf
3    Saint fefeee

我想把Saint替换成St,为了得到这个结果:

id   Ville
---------------
1    St azeraze
2    St ooiqsdf
3    St fefeee

如何使用replace 做到这一点?

UPDATE TheTable
SET Ville = REPLACE(Ville, '????', '????')
WHERE Ville LIKE 'Saint%'

【问题讨论】:

  • 我觉得没问题,你有什么错误吗?

标签: sql replace sql-server-2008-r2


【解决方案1】:
UPDATE TheTable
SET Ville = REPLACE(Ville, 'Saint ', 'St ')
WHERE Ville LIKE 'Saint %'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-20
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 2020-05-26
    • 2020-05-04
    相关资源
    最近更新 更多