原创: http://www.maomao365.com/?p=7215
摘要:
下文讲述从指定的字符串中将数字替换为指定字符
例:
将字符串中的数字替换为星号
数字通常为 0,1,2,3,4,5,6,7,8,9
我们可以依次将出现这些数字的地方替换为*,如下所示:
/* 新建数字匹配函数,将数字匹配为星号 */ create table test(info varchar(20)) insert into test(info)values('猫猫小屋122444.测试') insert into test(info)values('maomao365.com') go declare @i int =0 while @i<10 begin update test set info =replace(info,convert(varchar(1),@i),'*') set @i = @i+1 end select * from test go drop table test