Monday, May 19, 2008

Get details of identity columns in all the tables in the database,

To select value of identity columns in all tables in the selected database.
Below is the query which selects the description of identity columns in all tables in the selected database.

SELECT OBJECT_NAME(OBJECT_ID) AS
TABLENAME, NAME AS COLUMNNAME,
SEED_VALUE, INCREMENT_VALUE,
LAST_VALUE, IS_NOT_FOR_REPLICATION
FROM SYS.IDENTITY_COLUMNS ORDER BY 1

No comments: