Query to check whether a column is nullable (null values are allowed in the column or not). It should preferably return yes/no or 1/0 or true/false.
When you have to mention the column in the WHERE clause which contains null, you have two options: 1) Use a function ISNULL on the nullable column and 2) Use an additional OR condition to check the NULLABLE variables like Column IS NULL.
SELECT * FROM yourTableName WHERE yourSpecificColumnName IS NULL OR yourSpecificColumnName = ' '; The IS NULL constraint can be used whenever the column is empty and the symbol ( ' ') is used when there is empty value.
The IS NULL condition is used in SQL to test for a NULL value. It returns TRUE if a NULL value is found, otherwise it returns FALSE. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.
You could retrieve that from sys.columns
:
select is_nullable from sys.columns where object_id = object_id('Schema.TheTable') and name = 'TheColumn'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With