List all Nullable or Non-Nullable Columns in a SQL Server Table

To list all nullable columns in the 'Person.Address' Table in the AdventureWorks database, run the following query:

USE AdventureWorks
SELECT TABLE_CATALOG AS Database_Name, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Person'
AND TABLE_NAME = 'Address'
AND IS_NULLABLE = 'YES'

list_nullable_columns

To list all non-nullable columns in the 'Person.Address' Table in the AdventureWorks database, run the following query:

USE AdventureWorks
SELECT TABLE_CATALOG AS Database_Name, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Person'
AND TABLE_NAME = 'Address'
AND IS_NULLABLE = 'NO'

list_non_nullable_columns

Read related blog posts:
How to List all Columns in a SQL Server Table
How to check if the Column exists in a SQL Server Table

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">