Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

LIKE operator in CHAR fields with leading spaces in Oracle 12cR2

Ariagna Bandala salazarNov 5 2020 — edited Nov 11 2020

I am working with Oracle 12cR2 and with SQL Server 2014, performing some tests I found certain differences with the LIKE operator in both managers, the queries that give me different results are the following, the fields are of type char with a length of 40, in Oracle the collection of characters that I use at the column level is BINARY, NLS_SORT = BINARY_CI, NLS_COMP = LINGUISTIC and NLS_CHARACTERSET = WE8MSWIN1252, in SQL Server at the database level the character collection is Latin1_General_CI_AS and at the column level is Latin1_General_B:

SQL Server:
SELECT NAME FROM PEOPLE WHERE NAME LIKE 'JOSE'; Result: JOSE
SELECT NAME FROM PEOPLE WHERE NAME LIKE '%OSE'; Result: JOSE

Oracle:
SELECT NAME FROM PEOPLE WHERE NAME LIKE 'JOSE'; Result: No row has been selected
SELECT NAME FROM PEOPLE WHERE NAME LIKE '%OSE'; Result: No row has been selected
My question is, is there any configuration that needs to be done in Oracle to prevent it from taking the spaces to the right into account? Beforehand thank you very much

Comments
Post Details
Added on Nov 5 2020
5 comments
1,551 views