SQL 2005 UPDATE 问题
时间:2011-11-29
来源:互联网
表中有一字段的值存在着纯数字和中文的字符串,如
123
我爱你123、1223
我爱你123我爱你1234我爱你123
我爱你123我爱你
123我爱你
现在需要把这个字段中的前面和后面是中文的去掉,中间有中文或者符号的不管,更新后字段值为
123
123、1223
123我爱你1234我爱你123
123
123
请问SQL更新语句怎么写?
123
我爱你123、1223
我爱你123我爱你1234我爱你123
我爱你123我爱你
123我爱你
现在需要把这个字段中的前面和后面是中文的去掉,中间有中文或者符号的不管,更新后字段值为
123
123、1223
123我爱你1234我爱你123
123
123
请问SQL更新语句怎么写?
作者: yihuaheren011 发布时间: 2011-11-29
SQL code
create table tb(col nvarchar(30)) insert into tb select '123' insert into tb select '我爱你123、1223' insert into tb select '我爱你123我爱你1234我爱你123' insert into tb select '我爱你123我爱你' insert into tb select '123我爱你' go select substring(col,PATINDEX('%[^吖-做]%',col),len(col)-Patindex('%[^吖-做]%',REVERSE(col))-PATINDEX('%[^吖-做]%',col)+2) from tb /* ------------------------------ 123 123、1223 123我爱你1234我爱你123 123 123 (5 行受影响) */ go drop table tb
作者: qianjin036a 发布时间: 2011-11-29
更新:
SQL code
SQL code
create table tb(col nvarchar(30)) insert into tb select '123' insert into tb select '我爱你123、1223' insert into tb select '我爱你123我爱你1234我爱你123' insert into tb select '我爱你123我爱你' insert into tb select '123我爱你' go update tb set col=substring(col,PATINDEX('%[^吖-做]%',col),len(col)-Patindex('%[^吖-做]%',REVERSE(col))-PATINDEX('%[^吖-做]%',col)+2) select * from tb /* col ------------------------------ 123 123、1223 123我爱你1234我爱你123 123 123 (5 行受影响) */ go drop table tb
作者: qianjin036a 发布时间: 2011-11-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28