Skip Navigation Links
SQL Server 2012
SQL Server 2014
SQL Server 2016
Practice Test
Tip of the Day : Example Uses of the SYSDATETIME Date Function
SQL Server Helper
Home > > Tip of the Day
SQL Server Helper - Tip of the Day

To determine if a table contains an IDENTITY column, run the following statement:


A value of 1 means that the specified table has an IDENTITY column while a value of 0 means the table doesn’t have an IDENTITY column.  A value of NULL means either the table doesn’t exist or the object name passed is not a table.

To determine which column within a table is the IDENTITY column, run the following statement:

SELECT B.[Name] AS [IdentityColumn]
FROM [sys].[tables] A INNER JOIN [sys].[columns] B
  ON A.[Object_ID] = B.[Object_ID] AND
  A.[Name] = 'Company' AND
  COLUMNPROPERTY(A.[Object_ID], B.[Name], 'IsIdentity') = 1

Back to Tip of the Day List Next Tip