Search

Friday, June 8, 2012

Find all Identity Property Column in a Database

SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMNPROPERTY -- get columns where is_identity = 1
(OBJECT_ID(QUOTENAME(table_schema) + '.' + QUOTENAME(table_name)) -- table ID
,column_name, 'isidentity') = 1
ORDER BY table_name, ordinal_position

No comments:

Post a Comment