It's useful first.
Copy Code code as follows:
Use database
Update news set author= ' jb51 ' where author is null
If you're not right, that means you've got a wrong call somewhere. With a closer look, it is strongly recommended that you back up the database before doing so.
Description: Replaces NULL with the specified replacement value.
Syntax: 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: An expression to return when Check_expression is NULL. Replacement_value must be a type that can be implicitly converted to a check_expresssion type.
Return value: Returns the same type as check_expression.
Note: If check_expression is not NULL, it returns its value, otherwise, the former is returned when Replacement_value is implicitly converted to the type of check_expression, if the two types are different.
Instance:
Copy Code code as follows:
SELECT AVG (ISNULL (Weight, 50))
From Production.Product;
Analysis:
Do not use ISNULL to find NULL values. Instead, you should use is NULL. The following example finds all products that have NULL in the weight column. Please note the space between IS and NULL.
Copy Code code as follows:
Use ADVENTUREWORKS2008R2;
Go
SELECT Name, Weight
From Production.Product
WHERE Weight is NULL;
Go
SQL Server: How to determine whether a variable or field is NULL
Determines whether a variable is null:
IF (@VaribleName is NULL)
Select a record for which the field value is null:
WHERE column_name is NULL
ISNULL () function:
ISNULL (@VaribleName, ' defaultvalue ')
ISNULL (column_name, ' Default Value ')