1
Problem
When searching with texts containing apostrophes, no results are found.
Execution
DECLARE @cidade NVARCHAR(50)
SELECT @cidade = cidade FROM tabela_A WHERE id = xv
SELECT campo FROM tabela_B WHERE cidade = @cidade
The above example returns the result of the table_A with the city WATER EYE OF THE MARRIED MAN, but when performing the search in the tabela_B it does not return me anything.
When performing the search "manually", informing cidade = "OLHO D'AGUA DO CASADO"
the result is as expected.
Attempts
Assigning the city value to a variable, I tried using the functions QUOTENAME
and REPLACE
, but to no avail.
Marcelo, does the @city variable need to be Unicode? Is that, in the case of Unicode constants, it is necessary to be aware of the COLLATE of the objects involved.
– José Diz
Yes, it does, @J.D..
– Marcelo de Andrade