SQL Server Identity Info

WITH cte AS ( 
s.name + '.' + t.name AS TableName,
c.name AS ColumnName
FROM sys.tables t
INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
INNER JOIN sys.columns c ON c.object_id = t.object_id
AND c.is_identity = 1
IDENT_SEED(TableName) AS Seed,
IDENT_INCR(TableName) AS Increment,
IDENT_CURRENT(TableName) AS LastIdentity
FROM cte
order by TableName

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s