sqlServer中Replace函数的运用

replace(‘表中的字段’,‘要替换的字符’,‘替换后的新字符’)

       --建测试表:
       Create table #testTab
		(
			id int identity(1,1) primary key,
			NumberStr1 varchar(50) not null,
			NumberStr2 varchar(50) not null,
		)
		--增加测试数据
		insert  into #testTab values('123456','张B晨')
		insert  into #testTab values('123456','B福剑')
		--运用(将NumberStr1字段中包含123的值全部替换成一二三,将NumberStr2 字段中为B的替换成碧)
		SELECT NumberStr1=(REPLACE(NumberStr1,'123','一二三')),NumberStr2=(REPLACE(NumberStr2,'B','碧')) FROM #testTab;

演示效果展示:SqlServer常用函数

欢迎加入SqlServer交流群一起交流各种问题,群号:908518683

相关文章:

  • 2021-05-09
  • 2022-12-23
  • 2022-02-27
  • 2021-09-28
  • 2021-11-25
猜你喜欢
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
相关资源
相似解决方案