惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 潘伟

linux下快速查找文件大全 终于明白vi的用法了 什么是虚拟主机,为什么要使用虚拟主机? 一个存储前辈的一些业界知识(待了解) 10秒为任意数据库增加执行日志功能 - 潘伟 - 博客园 运动会的收获 从无奈到偷笑 一曲彩虹天堂 使用sql server中的全文索引经过大体的4个步骤 索引的创建 经常遇到的字段合并的问题 匹配符详解 系统表的应用 使用SQLServer2000 发送邮件详细配置过程 求记录中的最新数据的方法! 关于sql mail的配置问题(微软技术支持) 数据库设计范式深入浅出 锁定数据库的一个表_概述 约束的使用
数据库中的正则表达试
潘伟 · 2005-12-05 · via 博客园 - 潘伟

--数据装载
Create Table #T(Column1 varchar(20))
insert #T select '040011'
union all select '010021'
union all select '024综合'
union all select '021不知道'
union all select '031不'
union all select '不3'
union all select '知道'

--1:求包含数字,且长度为6的集合(包含了中文)

select * from #T  where Column1  like '%[0-9]%'  and len(Column1)=6

--结果
Column1             
--------------------
040011
010021
021不知道

(所影响的行数为 3 行)

--2:求包含中文,且长度为6的集合(包含了数字)

select * from #T  where Column1  like '%[^0-9]%'  and len(Column1)=6

--结果
Column1             
--------------------
021不知道

(所影响的行数为 1 行)

--3:求包含数字,且长度为6的集合(不包含中文)

select * from #T  where Column1 not like '%[^0-9]%'  and len(Column1)=6
--结果
Column1             
--------------------
040011
010021

(所影响的行数为 2 行)

--4 求所有记录只用中文的记录

select * from #T  where Column1 not like '%[0-9]%' 

--结果

Column1             
--------------------
知道

(所影响的行数为 1 行)

--5.求所有记录只有数字的记录

select * from #T  where Column1 not like '%[^0-9]%' 
--结果

Column1             
--------------------
040011
010021

(所影响的行数为 2 行)
或者

select * from #T  where isnumeric(Column1)=1

--结果

Column1             
--------------------
040011
010021

--6.查询数据中那条记录包含有中文

select case when Column1 like N'%[啊-座]%' then '包含中文' else '不包含中文' end
from #T

--结果

----------
不包含中文
不包含中文
包含中文
包含中文
包含中文
包含中文
包含中文

(所影响的行数为 7 行)

--7:只查询数字字段值

select * from #Twhere patindex('%[^-^0-9]%',Column1 )=0

--结果

Column1             
--------------------
040011
010021

(所影响的行数为 2 行)

--8:只查询中文字段值
select * from #T where patindex('%[^-^啊-座]%',Column1)=0

--结果

Column1             
--------------------
知道

(所影响的行数为 1 行)