Replace null string with null value

I have a table that has a string value of "null", which I want to replace with the actual value of NULL.

However, if I try to do the following in my choice

Select Replace(Mark,'null',NULL) from tblname 

It replaces all lines, not just lines with a line. If I change it to

 Select Replace(Mark,'null',0) from tblname 

It does what I expect and only changes those with the string "null"

+5
source share
1 answer

You can use NULLIF :

 SELECT NULLIF(Mark,'null') FROM tblname; 
+7
source

All Articles