Skip to content
Advertisement

Select Query is not working with WHERE clause when there is a space in column value

Select Query is not working with WHERE clause when there is a space in column value. since my table column value has space in it. When I copied same value from query result and put that with where clause, it doesn’t return any result. .

select * from myTable

enter image description here

if I run below query

select * From myTable where OldLoanNumber ='000000010383904 '

, it doesn’t return any result enter image description here

SQL Server Version is 18.6 as shown in pic enter image description here

Am I missing anything or any settings related to SQL Query Analyzer?

Advertisement

Answer

The ANSI standard says that string comparisons are to be padded to the same length, and I have observed that behavior many times.

I believe the most likely cause of your problem is the last character being a tab or other non space character that simply looks like a space to you.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement