views:

28

answers:

1

I am using SQL Server 2005 with the following query

SELECT * 
FROM EMPLOYEE 
WHERE EMP_NAME = 'ABCD'

It gave me the proper results and when i tried the same query with 'ABCD ', then also it gave me the same result!!!

I feel it should not give any results as there is no employee with name 'ABCD '

Or "WHERE" condition works like this with String comparison?

+3  A: 

Surprisingly, that's how it works!

INF: How SQL Server Compares Strings with Trailing Spaces:

For example, Transact-SQL considers the strings 'abc' and 'abc ' to be equivalent for most comparison operations.

INF: Behavior of ANSI_PADDING

Mitch Wheat