zoukankan      html  css  js  c++  java
  • sqlServer区分大小写查询

    sql server默认不区分大小写查询,但是有的时候部分查询语句却需要区分大小写查询,这个时候就需要进行一些特殊处理。区分大小写主要分两种方法。

    转二进制判断

    select * from table where cast(name as varbinary)=cast('LiYuanBa' as varbinary)               --短字符串
    select * from table where cast(name as varbinary)=cast('LiYuanBaABCEDEF……' as varbinary(500)) --长字符串
    

    注意

    varbinary默认长度为30,如果长度不够不保留超出的部分,最终导致判断错误!

    通过collate Chinese_PRC_CS_AS

    select * from table where name collate Chinese_PRC_CS_AS='LiYuanBa'        --精确
    select * from table where name collate Chinese_PRC_CS_AS like 'LiYuanBa%'  --模糊
    

    优点
    不需要考虑字符串长度问题,建议使用。

  • 相关阅读:
    AVFrame与Mat
    conda警告
    MS COCO数据集格式
    ubuntu卡在工作区切换界面
    C++编程便捷口
    Anaconda相关问题
    处理memory output
    ajax 上传form表单
    元类 metaclass
    小菜一碟
  • 原文地址:https://www.cnblogs.com/LFBlog/p/9049137.html
Copyright © 2011-2022 走看看