Technical Article

Tables With Identity Column

,

This script displays all tables in a database that has identity columns.

SELECT a.name table_names, b.name column_names,
 IDENT_INCR(a.name) AS IDENT_CURRENT, IDENT_INCR(a.name) AS IDENT_INCR,
   IDENT_SEED(a.name) AS IDENT_SEED,
    IDENT_INCR(a.name) + IDENT_CURRENT(a.name) NEXT_IDENTITY_NUMBER
FROM sysobjects a, syscolumns b
WHERE a.id = b.id
AND b.autoval is not null
ORDER BY a.name

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating