You are here:Home » tsql » Find Identity Property Column

Find Identity Property Column

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