Replace null string with null value
Matthew Barrera
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 tblnameIt replaces all rows and not just the rows with the string. If I change it to
Select Replace(Mark,'null',0) from tblnameIt does what I would expect and only change the ones with string 'null'
31 Answer
You can use NULLIF:
SELECT NULLIF(Mark,'null')
FROM tblname; 0