通常情况下写select * from 表名 where 列名 like 'AB%'但是这样,以小写ab开头的纪录也会被查找出来 如何查只以大写AB开头的呢?

解决方案 »

  1.   

    select * from 表名 where cast(left(列名,2) as varbinary(4))=cast('AB' as varbinary(4))
      

  2.   


    /*
    select * from AllTableData_BK 
    where TableName collate   Chinese_PRC_CS_AS_WS  like 'SO%'select * from AllTableData_BK 
    where TableName collate   Chinese_PRC_CS_AS_WS  like 'So%'
    */
    select * from 表名 where 列名 collate   Chinese_PRC_CS_AS_WS   like 'AB%'
    这就查询出区分大小的数据。。
      

  3.   

    collate Chinese_PRC_CS_AS_WS
    区分大小写
      

  4.   

    select * from tablename where left(colname,2)='AB'
      

  5.   

    select * from tbl where ascii(left(name,1))=65 and ascii(substring(name,2,1))=66实在不行用ASCII码来区分