I am writing a stored procedure in SQL where i have a scenario that fetch all record if parameter is null or fetch matching record if parameter is not null. In this case, i always use ISNULL function like that:
table.value = ISNULL(@param,table.value)
But in this case if value is not null, it works fine, but if value is null then it fetch all record except those where table.value is null. So i searched and found a solution here answered by sII. but i don't understand the statement
@param IS NULL OR value= @param
It works fine for me but i am unable to understand? How it works? Thanks in advance for answer.