SQL Server 中查询非中文,非英文,非数字的特殊列

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

今天在处理一个用户名数据库时,发现有些不正常的数据存在,按照逻辑,用户名只能是数字,字母,下划线和纯中文这样的字符组合存在,不应该有其他组合存在,但是发现数据库中由于各种历史原因,有些不正常的存在,如何找到这些异常数据,在CSDN的 SQL Server 版问了这样两个问题,如下:

 

http://topic.csdn.net/u/20100111/14/529a21a1-3ea8-4263-a0d9-34e83be79b1d.html

 

http://topic.csdn.net/u/20100111/15/c2a124c5-bc5b-4626-86ce-c5b862cf5cff.html

 

感谢CSDN的网友帮忙解决了这个问题,下面就是解决方法的汇总:

 
if object_id('[t1]') is not null  drop table [t1]create table [t1]([c] nvarchar(20))insert [t1]select 'aaa' union all  -- 此数据不应该被搜索到select 'bcds' union all  -- 此数据不应该被搜索到select 'a1' union all  -- 此数据不应该被搜索到select '啊' union all  -- 此数据不应该被搜索到select '^%' union all  -- 应该搜索到select 'ew1' union all  -- 此数据不应该被搜索到select '344' union all  -- 此数据不应该被搜索到select '__' union all  -- 此数据不应该被搜索到select '213_21' union all -- 此数据不应该被搜索到 select 'a_2' union all  -- 此数据不应该被搜索到select 'd' union all  -- 此数据不应该被搜索到select 'ddd' union all  -- 此数据不应该被搜索到select '电风扇' union all -- 此数据不应该被搜索到select '★思寒★' union all -- 应该搜索到select 'Ω' union all         -- 应该搜索到select 'トントン' union all -- 应该搜索到select '***' union all         -- 应该搜索到select '///' union all -- 应该搜索到select '@-@' union all         -- 应该搜索到select '@小慧' union all         -- 应该搜索到select '~*晓菊*~' union all -- 应该搜索到select '啊★洛' union all -- 应该搜索到select '不思議の夜' union all -- 应该搜索到select '(嘉宾)胡飞' union all -- 应该搜索到select '--------------'  -- 应该搜索到select * from [t1] WHERE PATINDEX('%[0-9a-z_]%',c)=0 and PATINDEX('%[^吖-座]%',c) <> 0

 

另外感慨一下,CSDN的 SQL Server 版 问出问题到解决问题,竟然比Google 搜索答案还要快, SQL Server 版 的牛人真多, 而且回答的这么快,实在让人吃惊。

           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
这里写图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值