none
SQL Server 2012 "LIKE" statement returns wrong results RRS feed

  • 問題

  • A bug was discovered on MS SQL Server 2012. When executing “Like” statement, the result is not as expected.

    In “TEST” table, it contains 5 row of records

    Id testc
    ------------------------------------------------------
    1 九龍九龍城工業工業區品
    2 香港香港城工業區
    3 香港九龍城工業區
    4 ABABCD
    5 九龍九龍塘九龍城工業區

    When running 
    select *
    from
    test
    where testc like '%九龍城%'

    Only records with id equal to 3, 5 are outputted, instead of outputting records with id equals to 1, 3, 5, which is a “correct” behavior on MS SQL Server 2005 and Oracle Server.

    And, 
    When running 
    select *
    from
    test
    where testc like '%ABC%'
    No record will be outputted, instead of outputting record with id equals to 4, which is a “correct” behavior on MS SQL Server 2005 and Oracle Server.

    It was found that repeating characters (“九龍” and “AB”) somehow affect “Like” operator in MS SQL Server 2012.

    Any ideas?

    2014年1月21日 上午 09:23

解答

  • Just saw this KB, and describe exactly the same problem I reported.  Solved in CU2.

    http://support.microsoft.com/kb/2785054/en-us

    • 已標示為解答 Rocky LO 2014年1月27日 上午 07:13
    2014年1月23日 下午 02:49

所有回覆