用新字符串更新任何等于8字符的字段的单元格 [英] update any cell of field that equal 8 charachter with new string

查看:77
本文介绍了用新字符串更新任何等于8字符的字段的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张下面的结构表:



1-customer_id int

2-tel_number nvarchar(20)

3-tel_type tinyint



在tel_number字段中存在数字,如44431223

现在我想添加字符串 76 到具有8个字符长度的单元格(如44331223)



示例:

执行查询之前tel_number字段内容为:

i have a table with below struct :

1-customer_id int
2-tel_number nvarchar(20)
3-tel_type tinyint

in tel_number field exists numbers like 44431223
now i want add string "76" to cells that has 8 character length (like 44331223)

example :
before execute query tel_number field contents is :

09167119004

44431223
44512112
44211451

09129874663





执行查询后tel_number字段内容为:



after execute query tel_number field contents is :

09167119004

7644431223
7644512112
7644211451

09129874663





如何编写执行此操作的SQL查询?



谢谢



How Do i Write SQL Query that do this operation ?

thanks

推荐答案

喜欢这个:



Like this:

UPDATE Customers
SET tel_number = ('76' + tel_number)
WHERE LEN(tel_number) = 8


这篇关于用新字符串更新任何等于8字符的字段的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆