Skip to content

Instantly share code, notes, and snippets.

@OskarKlintrot
Created January 3, 2018 09:31
Show Gist options
  • Save OskarKlintrot/90e12e5cfe9b9c0e56325cb2de65f665 to your computer and use it in GitHub Desktop.
Save OskarKlintrot/90e12e5cfe9b9c0e56325cb2de65f665 to your computer and use it in GitHub Desktop.
A SQL query to find all columns in a table that is not nullable (good to have ie when populating a table for testing)
USE DATABASENAME
DECLARE @table varchar(250) = 'TABLENAME'
SELECT name, is_nullable
FROM sys.columns
WHERE object_id = object_id(@table)
AND is_nullable = 0
ORDER BY name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment