Determine Whether a Table Has an Identity Column

This code is for MSSQL Server, but applicable for MS SSQL Server 7 or above. Check in T-SQL:

SELECT OBJECTPROPERTY(object_id('TableToBeChecked'), 'TableHasIdentity')

SQL Server returns 1 if the table has an identity column, 0 if it doesn’t.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist