Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help with a view

Author  Topic 

edb2012
Starting Member

19 Posts

Posted - 2014-07-31 : 13:02:25
Happy Thursday SQLTeam,

Having a rough start and I thought RTrim was going to work but the data fields I am working on have spaces after the values.

I tried these two ideas in SQL View on SQL 2008.

Select * from Customer where CustName = 'John Doe'

AND

Select * from Customer where (RTrim(CustName) = 'John Doe')

I got no results to either of these and there are 5 records of "John Doe" in field CustName.

Can anyone help me with this.

Really appreciate it javascript:insertsmilie('')

edb2012
Starting Member

19 Posts

Posted - 2014-07-31 : 13:12:23
Alright ... I solved my problem. When RTrim fails to fix my problem, Try the LIKE approach with a % ....

This worked ... elect * from Customer where CustName like 'John Doe%'

Sorry to bug everyone on this. Just had a Brain Fart.
Go to Top of Page

MichaelJSQL
Constraint Violating Yak Guru

252 Posts

Posted - 2014-07-31 : 13:15:44
If you have CustName='John Doe'

Is the attribute a Char or varchar?
do you have extra spaces in between or beginning?
did you check for special characters CHR(13) CHAR(10) etc..?
Is your Collation case sensitive? and John Doe is in your query ,but JOHN DOE in the database? probably not, but need to ask

try this just for troubles shooting WHERE CustName Like '%John%Doe%' see if you get results
Go to Top of Page
   

- Advertisement -