The curious case of trailing spaces in SQL

A while ago I was quite surprised to see that the following query returns 1 instead of 0:

[code lang=”sql”]
SELECT COUNT(*) WHERE N’Tim’ = N’Tim ‘; — notice the trailing space
[/code]

Apparently this is just standard behaviour. Here is an extract from sql1992.txt (Section 8.2 Paragraph 3):

One thought on “The curious case of trailing spaces in SQL

  1. Hi Tim,

    Thanks for the post, and thanks for pointing me to the post! Guess the offline network is still useful!

    -Kristof

Comments are closed.