select *
from tab
where
SecondaryInspSymbol = 'a'CreateTime SecondaryInspSymbol
------------------------------------------------------ -------------------
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A
2008-04-30 23:21:49.447 A最后结果不区分大小写
我想得到 SecondaryInspSymbol = 'a' 却把'A'的也查处来
如何区分大小写呢?
insert into @tb select 'ab'select * from @tb where s collate Chinese_PRC_CI_AS='aB' --不区分
select * from @tb where s collate Chinese_PRC_CS_AS='aB' --区分
select * from mytable where address = 'aaaa'
则两条记录都查出来了,我希望只得到一条记录,这样的SQL应该怎么写?create table #a(
[id] [char] (10),
[address] [char] (10)
)
insert into #a(id , address) values('1' , 'aaaa')
insert into #a(id , address) values('1' , 'aAAa')select * from #a where address = 'aaaa' COLLATE Chinese_PRC_CS_AS
select * from #a where address = 'aAAa' COLLATE Chinese_PRC_CS_ASdrop table #aid address
---------- ----------
1 aaaa (所影响的行数为 1 行)id address
---------- ----------
1 aAAa (所影响的行数为 1 行)如何查只以大写AB开头的呢?
通常情况下写select * from 表名 where 列名 like 'AB%'
但是这样,以小写ab开头的纪录也会被查找出来 如何查只以大写AB开头的呢?
select * from table where left(col,2) = 'AB%' COLLATE Chinese_PRC_CS_AS
select * from table where col like 'AB%' COLLATE Chinese_PRC_CS_AS
insert into tt select 'A'
insert into tt select 'a'alter table tt alter column name varchar(20) collate chinese_PRC_CS_As_wsselect * from tt
where name='A'
[id] [char] (10),
[address] [char] (10)
)
insert into #a(id , address) values('1' , 'aaaa')
insert into #a(id , address) values('1' , 'aAAa') select * from #a where address = 'aaaa' COLLATE Chinese_PRC_CS_AS
select * from #a where address = 'aAAa' COLLATE Chinese_PRC_CS_AS