There are a variety of functions in SQL, and the following will introduce you to the IsNull functions in SQL, including their syntax, comments, return types, and so on, for your reference, hoping to help you learn SQL.
ISNULL
Replaces NULL with the specified replacement value.
Grammar
ISNULL (Check_expression, Replacement_value)
Parameters
Check_expression
An expression that will be checked for null. Check_expression can be of any type.
Replacement_value
The expression that will be returned when check_expression is null. Replacement_value must have the same type as check_expresssion.
return type
Returns the same type as check_expression.
Comments
If Check_expression is not NULL, the value of the expression is returned, otherwise Replacement_value is returned.
Example
A. Using ISNULL with AVG
The following example finds the average price for all books and replaces all NULL entries in the Value column of the titles table with the values $10.00.
Use pubs
GO
SELECT AVG (ISNULL (Price, $10.00))
From titles
GO
Here is the result set:
--------------------------
14.24
(1 row (s) affected)
B. Using ISNULL
The following example selects the title, type, and price for all books in the titles table. If the price of a title is NULL, then the price shown in the result set is 0.00.
Use pubs
GO
SELECT SUBSTRING (title, 1,) as title, type as type,
ISNULL (Price, 0.00) AS-price
From titles
GO
Here is the result set:
Title Type Price
--------------- ------------ --------------------------
The Busy execut business 19.99
Cooking with Co business 11.95
You Can Combat business 2.99
Straight Talk A business 19.99
Silicon Valley Mod_cook 19.99
The Gourmet Mic mod_cook 2.99
The Psychology UNDECIDED
"Editor's recommendation"
Date formatting functions in the SQL Language getdate ()
The CHARINDEX function in SQL
Time functions in SQL
Statements copied from tables in SQL Server
How SQL Server can view the execution time of an SQL statement