Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS SQL where clause - comparison behaviour

Posted on 2013-01-09
1
Medium Priority
?
503 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 2000 total points
ID: 38761666
Yes and it can be overcome by like.
Reference:-http://support.microsoft.com/kb/316626
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

688 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