Solved

MS SQL where clause - comparison behaviour

Posted on 2013-01-09
1
501 Views
Last Modified: 2013-01-09
hi,

Wondering why in below 3 queries, the first and the second returns results when in fact '123' is not equal to '123  '? MS SQL trim trialing spaces automatically?

1) select * from Employee where EmployeeID='123'
2) select * from Employee where EmployeeID='123  '
3) select * from Employee where EmployeeID='  123'
0
Comment
Question by:sepknow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
TempDBA earned 500 total points
ID: 38761666
Yes and it can be overcome by like.
Reference:-http://support.microsoft.com/kb/316626
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question