微软BI开拓者

首页 » 数据库专区 » SQL Server开发 » 求助:排序规则与LIKE的一个实例
seusoftware - 3/22/2010 4:32:00 AM
--数据库排序规则为Chinese_PRC_CI_AS
select name,collation_name from sys.databases
GO

if OBJECT_ID('test') is not null
drop table test
GO

create table test
(
a varchar(40)
)
GO

insert into test
select '123A90' union all
select '123a90' union all
select '123B90' union all
select '123C90' union all
select '123c90'

select * from test

select *
from test
where a like '%[ABC]%'
collate Chinese_PRC_CS_AS

a
-------------
123A90
123B90
123C90

select *
from test
where a like '%[A-C]%'
collate Chinese_PRC_CS_AS

a
------------------
123A90
123B90
123C90
123c90
seusoftware - 3/22/2010 4:59:00 AM
select *
from test
where a like '%[A-C]%'
collate Chinese_PRC_BIN
seusoftware - 3/22/2010 4:59:00 AM
虽然这样可以了,但我还不明白,为什么
where a like '%[A-C]%'
collate Chinese_PRC_CS_AS
不行
1
查看完整版本: 求助:排序规则与LIKE的一个实例