REPLACE empty string
You can use CASE for this.
(CASE WHEN *YOURTHING* = '' THEN '0' ELSE *YOURTHING* END)
AS *YOURTHING*
There is nothing to replace in an empty string. REPLACE
replaces a sequence of characters in a string with another set of characters.
You could use NULLIF
to treat it as NULL
+ COALESCE
(or ISNULL
):
declare @value varchar(10);
set @value = '';
SELECT COALESCE(NULLIF(@value,''), '0')
This returns '0'
.