Chris Straw
SHARE:

Find SQL Tables with Identities

Spread the love
SELECT 
	OBJECT_ID(TABLE_SCHEMA + '.' + TABLE_NAME) ObjectId,
    IDENT_SEED(TABLE_SCHEMA + '.' + TABLE_NAME) AS Seed,
    IDENT_INCR(TABLE_SCHEMA + '.' + TABLE_NAME) AS Increment,
    IDENT_CURRENT(TABLE_SCHEMA + '.' + TABLE_NAME) AS Current_Identity,
    TABLE_SCHEMA + '.' + TABLE_NAME AS Table_Name
FROM 
    INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
    AND OBJECTPROPERTY(OBJECT_ID(TABLE_SCHEMA + '.' + TABLE_NAME), 'TableHasIdentity') = 1    

Written by

Chris Straw