5

In SQL Server, I am trying to select some of the records using a string which has space so I trim and use but something is wrong please correct me where something is missed by me.

SELECT * FROM projects where str_id=ltrim(rtrim('   artf130 ')) --- No rows selected
SELECT * FROM projects where str_id='artf130' -- one row selected

Update: I copied the first line from google spread sheet.

sunleo
  • 10,589
  • 35
  • 116
  • 196
  • 4
    Hello! Maybe take a look in here: http://stackoverflow.com/questions/14211346/how-to-remove-white-space-characters-from-a-string-in-sql-server And maybe give the answer a vote up. – Cataklysim Feb 09 '17 at 13:13
  • @Cataklysim thanks and given. – sunleo Feb 09 '17 at 13:18
  • @sunleo "so I trim and use but something is wrong please correct me" what is that 'something'? show us some sample data. – PowerStar Feb 09 '17 at 13:30
  • When I copied from google spread sheet some in-visible characters are there and, ltrim and rtrim could not remove them. – sunleo Feb 09 '17 at 13:42

1 Answers1

2

Maybe that was my bad. People keep helping. I think my comment was enough, cause I linked to a very similar problem, which got a answer. So here for everyone:

You can see the answer to that question here.

Community
  • 1
  • 1
Cataklysim
  • 637
  • 6
  • 21