declare @v varchar(3); -- it is null :) select isnull(@v, 1234) from_isnull, coalesce(@v, 1234) from_coalesce; go -- the above shows this in result window from_isnull from_coalesce ----------- ------------- * 1234The above deserves a splaining: isnull tries to cast 1234 (int) to varchar(3), it does not fit, but implementation of int calls to handle it and just return \*. coalesce just returns result as int because it is higher in the food chain.
-- this will error out (implicit conversion error) select isnull(59, getDate()) from_isnull; go -- this one will run just fine select coalesce(59, getDate()) from_coalesce; go from_coalesce ----------------------- 1900-03-01 00:00:00.000Why March 1? 2 reasons: 59 is converted to datetime (higher precedence), and 1900 was not a leap year, thus 59 days from Jan 1 is Mar 1, not Feb 29 :)
where (ev.is_deleted = 'N' or ev.is_deleted is null) and ev.start_dt = '20060701';and bingo, see that the predicate starts from the prefix column, so it can use the index if it decides it makes sense to do so.
No one has followed this question yet.