Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove spaces from string and select using that string in sql server

Tags:

sql

sql-server

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.

like image 615
sunleo Avatar asked Oct 30 '22 12:10

sunleo


1 Answers

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.

like image 199
Cataklysim Avatar answered Nov 15 '22 06:11

Cataklysim