TSQL Script to fetch the list of tables with identity properties

Below is the TSQL Script to fetch the list of tables in a database with identity column properties
[sql]
SELECT SCHEMA_NAME(T.SCHEMA_ID) AS SCHEMA_NAME,
OBJECT_NAME(T.OBJECT_ID) AS TABLENAME,
TI.NAME AS COLUMN_NAME,
TI.SEED_VALUE,
TI.INCREMENT_VALUE,
TI.LAST_VALUE AS LAST_VALUE
FROM SYS.TABLES AS T
INNER JOIN
SYS.IDENTITY_COLUMNS AS TI
ON T.OBJECT_ID = TI.OBJECT_ID
[/sql]

Leave a Reply

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