Monday, March 12, 2007

All tables with identity

I thought the following script is useful if you want to find out all tables with identity columns in a specific database.
use
go
SELECT
DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1
AND TABLE_TYPE = 'BASE TABLE'

No comments: