Solved

MS SQL where clause - comparison behaviour

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now