Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremykdev/bd54d9a5e3803b6c785210a23d7254b0 to your computer and use it in GitHub Desktop.
Save jeremykdev/bd54d9a5e3803b6c785210a23d7254b0 to your computer and use it in GitHub Desktop.
Find Microsoft SQL Server database tables without an identity column
SELECT
S.name AS SchemaName
,T.name AS TableName
FROM sys.tables AS T
INNER JOIN sys.schemas AS S ON ( T.schema_id = S.schema_id )
WHERE NOT EXISTS (
SELECT *
FROM sys.columns AS C
WHERE C.object_id = T.object_id
AND C.is_identity = 1
)
ORDER BY S.name, T.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment