Search This Blog & Web

Wednesday, May 9, 2012

Deciding between COALESCE and ISNULL in SQL Server


Problem

When writing T-SQL, a lot of developers use either COALESCE or ISNULL in order to provide a default value in cases where the input is NULL. They have various reasons for their choice, though sometimes this choice may be based on false assumptions. Some think that ISNULL is always faster than COALESCE. Some think that the two are functionally equivalent and therefore interchangeable. Some think that you need to use COALESCE because it is the only one that adheres to the ANSI SQL standard. The two functions do have quite different behavior and it is important to understand the qualitative differences between them when using them in your code.

Solution

The following differences should be considered when choosing between COALESCE and ISNULL:


................ By: 

A very good post i want to share it with all you guys.


http://www.mssqltips.com/sqlservertip/2689/deciding-between-coalesce-and-isnull-in-sql-server/

No comments: