数据库有十几万数据其中用户名中有2-3万的数据为中文,在sql中怎么才能查出包含中文的字段??
例如:name字段
aaa
张三
bbb
李四查询结果:张三
李四
例如:name字段
aaa
张三
bbb
李四查询结果:张三
李四
解决方案 »
- 一个取的表或者存储过程字段的问题
- 把EXEC返回的内容存入变量中.
- 精通“存储过程”的高手进来!!!! 昨天的问题------续~~~~~~
- 如果把一个大文件放入数据库 会出现什么不良反映吗?
- 请教SQL-SERVER 如何插入测试数据的问题
- sql server 2005装不上
- 关系运算中有“除”,“笛卡尔积”,这两个在SQL语言中应该怎么样表示?
- 急!!!在线等待
- SQL SERVER 2005 DDL 触发器的问题......了解的来看看....
- 请教一下,如何实现数据分列,谢谢
- The data types ntext and varchar are incompatible in the equal to operator.
- sql查询语句的效率
from tb
where patindex('%[1-9]%',name)<0
---------------------------------
-- Author: htl258(Tony)
-- Date : 2009-07-30 20:33:09
---------------------------------
--> 生成测试数据表:tbIf not object_id('[tb]') is null
Drop table [tb]
Go
Create table [tb]([name] nvarchar(3))
Insert tb
Select 'aaa' union all
Select '张三' union all
Select 'bbb' union all
Select '李四'
Go
--Select * from tb-->SQL查询如下:
select * from tb where name like '%[吖-做]%'
/*
name
----
张三
李四(2 行受影响)
*/
select * from tb where patindex('%[吖-做]%',name)>0
/*
name
----
张三
李四(2 行受影响)
*/
-- -----------t_mac 小编-------------
---希望有天成为大虾----
-- =========================================IF OBJECT_ID('tb') IS NOT NULL
DROP TABLE tb
GO
CREATE TABLE tb(name varchar(20))
go
insert tb SELECT
'aaa' UNION ALL SELECT
'张三' UNION ALL SELECT
'bbb' UNION ALL SELECT
'李四'
go
select *
from tb
where name not like'%[a-z]%'
go
/*------------
(4 行受影响)
name
--------------------
张三
李四
-------*/
from tb
where PATINDEX('%[a-z]%',name)=0
/*name
--------------------
张三
李四(2 行受影响)*/
select count(*) from bbb where name like '%[吖-做]%' ------结果为1.5w ------------这个是name中只包含中文?如果有数字、英文都不行?select count(*) from bbb where name not like'%[a-z]%' ------结果为2.2w
------------这个是name中只能有英文,不能有数字和中文?
Drop table [tb]
Go
Create table [tb]([name] nvarchar(8))
Insert tb
Select 'aaa' union all
Select '张三11' union all
Select 'bbb' union all
Select '李四aa'
Go
--Select * from tb-->SQL查询如下:
select * from tb where name like '%[吖-做]%'
/*
name
--------
张三11
李四aa(2 行受影响)
*/
select count(*) from bbb where name like '%[吖-做]%' 这个只要包含中文都能查出select count(*) from bbb where name not like'%[a-z]%' 这个只要有英文的,哪怕中文加英文都查不出总结:第一个准谢谢大家
--这个可以查全英文或英文与其它字符的组合。