Replace Null String with Null Value
I Have a Table That Has a String Value of 'Null' That I Wish to Replace with an Actual Null Value. However If I Try to Do the Following in My Select Select...
I have a table that has a string value of 'null' that I wish to replace with an actual NULL value.
However if I try to do the following in my select
Select Replace(Mark,'null',NULL) from tblname
It replaces all rows and not just the rows with the string. If I change it to
Select Replace(Mark,'null',0) from tblname
It does what I would expect and only change the ones with string 'null'
1 Answer
You can use NULLIF:
SELECT NULLIF(Mark,'null')
FROM tblname;