Comparing strings with trailing spaces
June 30, 2014 Leave a comment
select top 1 * from database.dbo.table WHERE 1=0 — returns no results
— makes sense
select top 1 * from database.dbo.table WHERE 1=1 — returns 1 row
— yep
select top 1 * from database.dbo.table WHERE ‘frog’ = ‘frog’ — returns 1 row
— cool
select top 1 * from database.dbo.table WHERE ‘frog’ = ‘frog ‘ — returns 1 row
— eh!!?
Apparently it’s by design – http://support.microsoft.com/kb/316626
I didn’t know that!