Home » To find all the tables that have an identity column

To find all the tables that have an identity column

I find the below query useful in identifying all the tables that have an identity column in it.

SELECT SCHEMA_NAME(schema_id) AS schema_name
, t.name AS table_name
, c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.object_id = c.object_id
ORDER BY schema_name, table_name;
GO

Leave a Reply

Your email address will not be published. Required fields are marked *