How to replace NULL with a different value in a query result in SQL Server

When you select rows from a table, the results may contain NULL values:

USE AdventureWorks
SELECT Name, Weight
FROM Production.Product


If you want to replace the NULL values with some other value in query results, use ISNULL System Function that replaces NULL with a specified value:

USE AdventureWorks
SELECT Name, ISNULL (Weight, 0) AS Weight
FROM Production.Product


Type of the replacement value is converted to the type of original replaced value, if the types are different.
If the conversion fails, you will get an error similar to this:

Msg 8114, Level 16, State 5, Line 2
Error converting data type varchar to numeric.


The replacement value is truncated if it is longer than the original value.