如何替换列中的前2个字符 [英] How to replace first 2 characters in a column
问题描述
大家好,
如何替换列中的前2个字符
例子:
28850223169
28850256169
28770223169
28602231698
28950111169
这里前两个数字应该替换为39它将会是
39850223169
39850256169
39770223169
39602231698
39950111169
如何替换那样请告诉我怎么做
i尝试过这样但是
Hi Guys ,
How to replace first 2 characters in a column
examplle :
28850223169
28850256169
28770223169
28602231698
28950111169
Here first 2 number should replace with 39 it wold be
39850223169
39850256169
39770223169
39602231698
39950111169
How to replace like that please tell me how to do
i have tried like this but
UPDATE number
SET num = replace(num, '28', '39')
替换39,其中有28个存在,但我只需将前2个数字更改为39
请告诉我们怎么做
谢谢和问候
mani
its replacing 39 where ever 28 present but i need to change only first 2 numbers to 39
Please tell me guys how to do
thanks and regards
mani
推荐答案
最好的方法将使用子字符串修剪前两个字符,然后在前面加上'39':
The best way would be to trim the first two characters using substring and then prepend it with '39':
UPDATE number
SET num = '39'+substring(num, 3, len(num))
hi,< br $> b $ b
也可以尝试这个。
Try this one too.
UPDATE number
SET num= Replace(num, Substring(num, 1, 2), 39)
符合您的要求:
its match your requirement :
UPDATE number
SET num= '39'+''+right(num, Len(num)-2)
谢谢
Dhamu
Thanks
Dhamu
这篇关于如何替换列中的前2个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!