我们在开发系统的时候经常会碰到类似如下这样的情况:比如我有一张数据表

SQLServer如何批量替换某一列中的某个字符串

假如我现在要把红圈中这列的的http://www.mylanqiu.com/ 这个字符串批量替换成mylanqiu 这个字符串,这个要怎么实现?其实这个很简单,只要使用SQL的Replace函数就可以了,代码如下:

 update [HelloCode].[dbo].[AD]
  set [Contents]=REPLACE([Contents],'http://www.mylanqiu.com/','mylanqiu')
  where  Contents like '%www.mylanqiu.com%'

Replace函数的用法:

Replace(数据库的列名,'要被替换掉的字符串','要用于替换的字符串')

相关文章:

  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-01-26
  • 2022-01-28
  • 2022-12-23
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案