Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's a quirk of the standards apparently. Might as well be explicit:</p> <blockquote> <p>SQL Server follows the ANSI/ISO SQL-92 specification (Section 8.2, , 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, <strong>Transact-SQL considers the strings 'abc' and 'abc ' to be equivalent</strong> for most comparison operations.</p> <p><strong>The only exception to this rule is the LIKE predicate</strong>. 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.</p> </blockquote> <p>See <a href="http://support.microsoft.com/kb/316626" rel="nofollow noreferrer">here</a>, <a href="http://richarddingwall.name/2007/12/28/t-sql-equality-operator-ignores-trailing-spaces/" rel="nofollow noreferrer">here</a> and <a href="https://stackoverflow.com/questions/1399844/sql-server-2008-empty-string-vs-space">here</a>. </p> <p>Bizarre - given the terms "equal" and "like" I would have expected the latter to be the more liberal.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload