The primary difference between your examples is that the latter does not replace NULL with your default value.
With regard to performance, you will generally need to try very hard to find a measurable difference (in the order of a few seconds over millions of rows). Search for performance measures for isnull, coalesce, and case--you'll find lots of blog posts about them.
The common voice I've heard is that you should use the structure that feels the most readable for your team, and any time you get the feeling that it might not be as performant as it could be, test it. Run it both ways, and compare the time it takes to complete, and compare the execution plans.
Answer from SQLFox on Stack ExchangeVideos
I'd move the ISNULL outside of the subquery - what if the subquery returns no results?
set @test = COALESCE(
(select NULLIF(discnumber,'')
from discmaster
where meteredfilename = '3501' or nonmeteredfilename='3501')
,'NA')
(I've also been a snob and replaced ISNULL with COALESCE. Outside of a few scenarios, COAELSCE is the better function).
Instead of ISNULL(NULLIF(discnumber,''),'NA')
try COALESCE(discnumber,'NA')
Remember that NULL is different from 0. So the two code snippets in the question can return different results for the same input.
For example, if BeginningQuantity is NULL, the first expression evaluates to NULL:
CASE WHEN (NULL + ?)=0 THEN 0 ELSE ?/(NULL + ?) END
Now (NULL + ?) equals NULL, and NULL=0 is false, so the ELSE clause is evaluated, giving ?/(NULL+?), which results in NULL. However, the second expression becomes:
ISNULL((?)/NULLIF(NULL + ?,0),0)
Here NULL+? becomes NULL, and because NULL is not equal to 0, the NULLIF returns the first expression, which is NULL. The outer ISNULL catches this and returns 0.
So, make up your mind: are you guarding against divison by zero, or divison by NULL? ;-)
In your example I think the performance is negligible. But in other cases, depending on the complexity of your divisor, the answer is 'it depends'.
Here is an interesting blog on the topic:
For readability, I like the Case/When.