I have data where some records contain blank rows (=no space, no NULL). E.g.:
LOCALE
en-es
en-uk
uk-uk
When I want to select that blank row, it's easy with:
SELECT LOCALE
FROM ABC
WHERE LOCALE = ''
But when I try to replace it as follows, it does not work, the result is still blank row:
SELECT REPLACE(LOCALE,'','WHY') AS 'LOCALE'
FROM ABC
WHERE LOCALE = ''
But if I bypass this with CASE
statement, it works:
SELECT CASE
WHEN LOCALE LIKE '' THEN 'WHY'
ELSE LOCALE
END AS 'LOCALE'
FROM ABC
WHERE LOCALE = ''
What is the problem here? Why does REPLACE
function not work?
It is obvious that
''
means blank (Not null) and it exists between two consecutive letters also. (As it is blank)So Sql can not go on replacing that blank in between every letter with the string you want. That's why you can not replace
''
Check this query