I have a table with a varchar(100) column that has some empty values. When I try to replace the empty strings with a value, nothing happens. I cannot figure out why. I am sure the value in the cells is not null. I can reproduce with a temporary table and some sample data.
The below SQL should return a result set in which the [ReplacedTextCol] always has a value, but even when using replace, I cannot replace the empty string:
create table #tempt
(
col1 varchar(100)
)
insert into #tempt(col1)
values('')
,('')
,('some value')
select replace(col1, '','replaced') as ReplacedTextCol,*
from #tempt
The result of the above query is shown below:
Table, DB & server uses the collation SQL_Latin1_General_CP1_CI_AS
Appreciate any pointer as to where I'm going wrong.

abcd? What you ask should either match all characters as if it were a wildcard, or nonecase whenorIIF()instead of REPLACE. You're looking for an exact match after all, not find an empty string inside another string. Eg useIIF(col1='','replaced',col1)