Solved

MS SQL where clause - comparison behaviour

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

920 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

14 Experts available now in Live!

Get 1:1 Help Now