原創: 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

