0
I am trying to make an SQL query, but it returns the following error: "Error Converting data type varchar to Numeric."
SELECT Tabela1.CPF, Tabela2.CPF
FROM Tabela1
INNER JOIN Tabela2
ON Tabela1.CPF = Tabela2.CPF
I verified that the CPF field of Table 1 is Numeric and the CPF field of Table 2 is varchar. I did the varchar to Numeric type conversion using the CAST() function, but continued to get the same error message: "Error Converting data type varchar to Numeric.":
SELECT Tabela1.CPF, CAST(Tabela2.CPF AS NUMERIC)
FROM Tabela1
INNER JOIN Tabela2
ON Tabela1.CPF = CAST(Tabela2.CPF AS NUMERIC)
Why the conversion is not working?
You probably have some data that is not just numbers... That’s why of this mistake.
– Bruno Warmling
Convert the number to char this does not give error , use also a Trim , the performance should be impaired.
– Motta
I converted Numeric to scan and managed to run the query successfully.
– Alineat
In the CPF column of Tabela2 there are only digits or digits and "." and "-"? Post data sample...
– José Diz