Both IsNull() and Coalesce() are used for dealing with null values. And, they differ in following ways.
IsNull Function
IsNull Function
- This is not a standard SQL function. i.e if you migrate from SQL Server to Some other RDBMS this function will not work.
- IsNull() function takes 2 arguments. Such that, if value of first argument is null then it is replaced with non null value from second argument.
- This function always replaces NULL with second argument, Hence Non NULL value is guaranteed.
- Syntax: IsNull(Col1,0)
- Coalesce() is standard SQL Function so porting is easy.
- It allows n number of argument and replaces null value in first argument with Value of first non null value argument from rest of the arguments.
- Non NULL value is not guaranteed. Because, if all arguments return Null value, Value return by Coalesce is also NULL.
- Coalesce(Col1, Col2, Col3,....,Coln)
No comments:
Post a Comment