I discover some behavior I didn't know before. Why this line of code does not work?
SELECT REPLACE('','','0') ==> returns ''
I can't even have ''
in where condition. It just doesn't work. I have this from imported Excel where in some cells are no values but I'm not able to remove them unless I used LEN('') = 0
function.
String.Replace Method (String, String)Use String. Empty or null instead of "" since "" will create an object in the memory for each occurrences while others will reuse the same object.
Use the boolean OR operator to convert None to an empty string in Python, e.g. result = None or "" .
An empty string is a String object with an assigned value, but its length is equal to zero. A null string has no value at all. A blank String contains only whitespaces, are is neither empty nor null , since it does have an assigned value, and isn't of 0 length.
The Java programming language distinguishes between null and empty strings. An empty string is a string instance of zero length, whereas a null string has no value at all. An empty string is represented as "" . It is a character sequence of zero characters. A null string is represented by null .
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'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With