• It would have been a good idea to reference http://msdn.microsoft.com/en-us/library/ms187330.aspx as well as the coalesce page, because people thinking that if no value is returned the value is set to null is a pretty common error. I must have explained a few dozen times over the years that

    select @a = iValue from @vals where iKey <> iValueand

    set @a = (select iValue from @vals where iKey <> iValue)behave completely differently when the filter passes no rows.

    Tom