查询区分大小写
来源:互联网 发布:java获取工程绝对路径 编辑:程序博客网 时间:2024/05/17 01:59
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在sql2000和7.0的查询语句中,区分大写的查询方法
--sql2000,就用下面的方法.
--就是在字段名后加collateChinese_PRC_CS_AS_WS
--区分大小写、全半角字符的方法
--测试数据
createtable表(fdvarchar(10))
insertinto表
selectaa='aa'
unionallselect'Aa'
unionallselect'AA' --全角A
unionallselect'A,A' --全角A,半角,
unionallselect'A,A' --全角A,全角,
go
--查询
--1.查大写字母
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%A%'
--就是在字段名后加collateChinese_PRC_CS_AS_WS
--2.查全角
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%A%'
--3.查半角
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%,%'
go
--删除测试数据
droptable表
/*--测试结果
1.查询大写字母的结果
fd
----------
Aa
2.查询全角字符的结果
fd
----------
AA
A,A
A,A
3.查询半角字符的结果
fd
----------
A,A
(所影响的行数为1行)
--*/
================================================================
--sql7.0,就用下面的方法.
--如果是全部比较
--下面是测试
select*from(
selectfd='a'
unionallselect'A'
)a
wherecast(fdasvarbinary(8000))=cast('A'asvarbinary(8000))
/*--测试结果
fd
----
A
(所影响的行数为1行)
--*/
--如果是部分匹配,就用charindex:
--下面是测试
select*from(
selectfd='a'
unionallselect'A'
unionallselect'aAaa'
unionallselect'aaaa'
unionallselect'cccA'
)a
wherecharindex(cast('A'asvarbinary(8000)),cast(fdasvarbinary(8000)))>0
/*--测试结果
fd
----
A
aAaa
cccA
(所影响的行数为3行)
--*/
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在sql2000和7.0的查询语句中,区分大写的查询方法
--sql2000,就用下面的方法.
--就是在字段名后加collateChinese_PRC_CS_AS_WS
--区分大小写、全半角字符的方法
--测试数据
createtable表(fdvarchar(10))
insertinto表
selectaa='aa'
unionallselect'Aa'
unionallselect'AA' --全角A
unionallselect'A,A' --全角A,半角,
unionallselect'A,A' --全角A,全角,
go
--查询
--1.查大写字母
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%A%'
--就是在字段名后加collateChinese_PRC_CS_AS_WS
--2.查全角
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%A%'
--3.查半角
select*from表
wherefdcollateChinese_PRC_CS_AS_WSlike'%,%'
go
--删除测试数据
droptable表
/*--测试结果
1.查询大写字母的结果
fd
----------
Aa
2.查询全角字符的结果
fd
----------
AA
A,A
A,A
3.查询半角字符的结果
fd
----------
A,A
(所影响的行数为1行)
--*/
================================================================
--sql7.0,就用下面的方法.
--如果是全部比较
--下面是测试
select*from(
selectfd='a'
unionallselect'A'
)a
wherecast(fdasvarbinary(8000))=cast('A'asvarbinary(8000))
/*--测试结果
fd
----
A
(所影响的行数为1行)
--*/
--如果是部分匹配,就用charindex:
--下面是测试
select*from(
selectfd='a'
unionallselect'A'
unionallselect'aAaa'
unionallselect'aaaa'
unionallselect'cccA'
)a
wherecharindex(cast('A'asvarbinary(8000)),cast(fdasvarbinary(8000)))>0
/*--测试结果
fd
----
A
aAaa
cccA
(所影响的行数为3行)
--*/
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 查询区分大小写
- 查询区分大小写
- SQL查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 查询区分大小写
- 管理员DBA
- 自定义函数,仿VBA中域函数DLookup
- 手把手教你玩转ARP包(二)【数据包的游戏系列之一】
- YUI
- 【CSplitterWnd技巧一】改变分割窗口拖动条的大小
- 查询区分大小写
- 【CSplitterWnd技巧二】使分割窗口不能改变大小
- ERP基础档案管理模块中实现多级分类档案级联删除技术
- WhatsnewisMicrosoft2000(五)
- 手把手教你玩转ARP包(完)【数据包的游戏系列之一】
- ERP体现的管理思想之众说纷纭-安尚
- 1.1 什么是编程语言:如何像计算机专家一样思考(C++版
- WhatsnewinMicrosoft2000(六)
- 如何配置Tomcat 5和IIS 5协同工作