devxlogo

Determine Whether a Table Has an Identity Column

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.

devx-admin

Share the Post: