I have been testing H2 and for some reason same strings with trailing 
spaces are considered different. For Example:

select CASE WHEN 'testing'='testing     ' THEN 'SAME' ELSE 'DIFFERENT' END

H2 returns 'DIFFERENT' on that query, MSSQL does not, which it seems to be 
the right way. Looking for info on how this should work I found this from 
the MSSQL Server:

SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, 
<Comparison Predicate>, General rules #3) on how to compare strings with 
spaces. The ANSI standard requires padding for the character strings used 
in comparisons so that their lengths match before comparing them. The 
padding directly affects the semantics of WHERE and HAVING clause 
predicates and other Transact-SQL string comparisons. For example, 
Transact-SQL considers the strings 'abc' and 'abc ' to be equivalent for 
most comparison operations.

The only exception to this rule is the LIKE predicate. When the right side 
of a LIKE predicate expression features a value with a trailing space, SQL 
Server does not pad the two values to the same length before the comparison 
occurs. Because the purpose of the LIKE predicate, by definition, is to 
facilitate pattern searches rather than simple string equality tests, this 
does not violate the section of the ANSI SQL-92 specification mentioned 
earlier.

So maybe there is a setting I'm missing?

JDBC URL: jdbc:h2:tcp://localhost/.\mydatabase

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/b61a6e62-33ec-4295-885f-03dcc611584c%40googlegroups.com.

Reply via email to