I am trying to check if both databases have different values, then show else not.
The target db has the same value but with leading spaces, yet I want it to remove the spaces and consider it the same, but still it's showing me that it's different. Why?
Use TargetTestingDb
SELECT TRIM(ISNULL(Name,'')) Name
,TRIM(ISNULL(cs.ContinentName,'')) ContinentName
,DisplayOrder
,GroupName
FROM TestingDb.dbo.Country cs
WHERE NOT EXISTS (
SELECT 1
FROM Country ct
WHERE TRIM(ISNULL( N'?????', '')) = TRIM(ISNULL(ct.ContinentName, ''))
AND TRIM(ISNULL(cs.Name, '')) = TRIM(ISNULL(ct.Name, ''))
)
the text is in Arabic i.e. N'?????
But when I remove spaces from ct.ContinentName then it starts working.
Note: for convenience, I have replaced the column name with the Arabic value.
Target table in TargetTestingDb
Id ContinentName Name
216 ????? ?????
Source table TestingDb
Id ContinentName Name
218 ????? ?????
TargetTestingDb country has a space in it. That's fine
But still my query is showing it as if it doesn't exist.
Update:
Datatype is nvarchar(max)
Update:
tried it's working for trailing but not leading spaces
SELECT ct.ContinentName, TRIM(ISNULL(ct.ContinentName, '')) FROM Country ct WHERE TRIM(ISNULL( ct.ContinentName, '')) = TRIM(ISNULL(N'????? ', ''))
but then i remove this spaces from ????? it works.