简体   繁体   English

SQL Server 2005条件与字符串比较

[英]SQL Server 2005 where condition with string comparison

I am using SQL Server 2005 with the following query 我将SQL Server 2005与以下查询配合使用

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!!! 它给了我正确的结果,当我尝试使用'ABCD '进行相同的查询时,它也给了我相同的结果!

I feel it should not give any results as there is no employee with name 'ABCD ' 我觉得它不会给出任何结果,因为没有名称为'ABCD '员工

Or "WHERE" condition works like this with String comparison? 还是“ WHERE”条件通过字符串比较像这样工作?

Surprisingly, that's how it works! 令人惊讶的是,它就是这样工作的!

INF: How SQL Server Compares Strings with Trailing Spaces : INF:SQL Server如何比较字符串与尾随空格

For example, Transact-SQL considers the strings 'abc' and 'abc ' to be equivalent for most comparison operations. 例如,Transact-SQL认为字符串“ abc”和“ abc”在大多数比较操作中是等效的。

INF: Behavior of ANSI_PADDING INF:ANSI_PADDING的行为

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM