while doing select in MS SQL very often NULL and '' can be treated identical. There is good description to Combine These: how to use null or empty string
However I wonder if it make sense to put this into a user defined function to simplify queries for this. Does anybody uses such function? Are there strong pro and cons on this one?
''andNULLmay not represent the same thing. As a very simple idea, you could have a Yes/No question on your website/application. Values of''could represent that the customer has not answered the question, when it was presented to them, however,NULLmay represent that the customer hasn't answered and it isn't applicable, or they haven't been given the opportunity (perhaps they registered before the question was added). I would never say yes''andNULLrepresent the same thing without knowing the data they represent.WHERE. Scalar functions, however, are notoriously slower compared to Table-Value Function, but then it could look messy in yourFROMclause. Personally, if you know that for that columnNULLalso means''use anORclause:AND (YourColumn = '' OR YourColumn IS NULL). Or, otherwise, if you don't wants NULLs, then use anUPDATEstatement to change theNULLvalues to''and then set the column to be non-NULLable.