Solved

MS SQL where clause - comparison behaviour

Posted on 2013-01-09
1
500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

734 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