wbh
February 10, 2016, 9:03am
1
Hello
I have a data problem:
I have a table that has two columns:
col1 (int)
col2 (nvarchar (255))
col1 col2
1 NAME1
2 NAME2
3 TUNISIA TELECOM
data tables that were imported from an Excel file and fueled by my application
I have a problem reading certain data (not all)
example:
select * from mytable Where col2 like 'TUNISIA%': it works
select * from mytable Where col2 like 'TUNISIA%': it does not work
select * from mytable Where col2 like 'TUNISIA t%': it does not work
The problem is in the space character
what do I have to do?
thank you
khtan
February 10, 2016, 12:23pm
2
Check that it is really a SPACE or other unprintable character
Or use CLEAN() in excel to remove any before you import in.
wbh
February 10, 2016, 1:28pm
3
how to know the character?
According to the display is a space
I even tried the ASCII code (255 alt), still nothing
The problem is that it's been that I imported data from EXCEL (myself) but I have not received this complaint from my client now
are there a way to see the hidden character?
khtan
February 10, 2016, 1:39pm
4
use SUBSTRING() to extract 1 character and then use ASCII() to view the ascii code
wbh
February 10, 2016, 2:14pm
5
I found the character, code 32
I wrote this query and it works
UPDATE mytable SET col2= REPLACE(col2, ' ', ' ')
(code 32
thank you khtan
khtan
February 10, 2016, 10:16pm
6
ASCII 32 is SPACE and your replace statement basically replace space with space.
kazeem
February 11, 2016, 9:14am
7
Use TRIM functions to ignore spaces while selecting. Such as
select * from mytable Where LTRIM(RTRIM(col2)) like 'TUNISIA%'