So far I've been using ISNULL(dbo.fn_GetPrice(ItemId), 0)
to make it not nullable (rather call it default-valued, but whatever).
Is this the right way?
Yes, that is the right way to do it. By using the isnull
function you are creating an expression that must return a value, no matter what. This is evaluated by SQL Server to be a computed column that is not null
.