How to resolve "variable 'x' can't be set to the value of 'null'" in sql?

Example:

SET @unknown_variable = NULL;
This message appears when you try to set a variable to NULL that doesn’t support NULL values.

Solution:

-- Use a value other than NULL or ensure the variable can accept NULL values.

Beginner's Guide to SQL