Remove numbers from string sql server(从字符串 sql server 中删除数字)
问题描述
我有一个大型数据库,我想在其中进行部分字符串搜索.用户将输入字符:JoeBloggs.
I have a large database in which I want to do a part string search. The user will enter characters: JoeBloggs.
为了争论,如果我在数据库中有一个名字Joe 23 Blo Ggs 4.我想删除 A-Z 以外的名称中的所有内容.
For arguments sake if I had a name Joe 23 Blo Ggs 4 in the database. I want to remove everything in the name other than A-Z.
我有 REPLACE(Name, ' ','') 函数来删除空格和 UPPER() 函数来将名称大写.
I have the REPLACE(Name, ' ','') function to remove spaces and the UPPER() function to capitalize the name.
是否有更有效的快速方法可以通过正则表达式来替换 A-Z 以外的任何内容.我无法更改数据库中的值.
Is there a more efficient fast way maybe by terms of regex to replace anything other than A-Z. I cannot change the values in the database.
推荐答案
第一个选项 -
您可以将 REPLACE() 函数嵌套到 32 层深.它运行得很快.
You can nest REPLACE() functions up to 32 levels deep. It runs fast.
REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE
(REPLACE (@str, '0', ''),
'1', ''),
'2', ''),
'3', ''),
'4', ''),
'5', ''),
'6', ''),
'7', ''),
'8', ''),
'9', '')
第二个选项——做相反的 -
2nd option -- do the reverse of -
从数字中移除非数字数据 + SQL
第三个选项 - 如果你想使用正则表达式
3rd option - if you want to use regex
然后http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=27205
这篇关于从字符串 sql server 中删除数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从字符串 sql server 中删除数字
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- SQL 临时表问题 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
