Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a table in my SQL Server. I have copied all the data from an excel to table. When I am querying the data like this..
SQL
SELECT [App_Name],[Link],[Comments] FROM [App_Links] where Env_Ref_ID=1 
and App_Name = 'O2'


I am not getting the result. But I have O2 in my table when queries as
SQL
SELECT [App_Name],[Link],[Comments] FROM [App_Links] where Env_Ref_ID=1 

Issue is Column App_Name has got some space or other special characters it seems. I even tried with this..
SQL
SELECT [App_Name],[Link],[Comments] FROM [App_Links] where Env_Ref_ID=1 
and LTRIM(RTRIM( App_Name)) = 'O2'  order by Link

but was no use. When I tried to copy cell data it was like this 'O2 '.
Any suggestion son this please.
Thanks
Sreenath
Posted
Updated 19-May-11 0:51am
v2

Update your table with all unwanted characters replaced/removed.
 
Share this answer
 
It looks like you are querying on '02' but the data is 'O2'. In other words you are looking for zero-two but it contains the letter O plus the two.
 
Share this answer
 
Comments
Sreenath Gv 19-May-11 6:57am    
No..its O2 only....it is wroking with like token...
Data clean up will the best option to improve your maintainability index. else please try by using LIKE keyword instead of =
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900