There are actually two ways in which you can find out whether a given column name is an identity or not in SQL Server:
- Method One:
Select ColumnProperty(Object_id('Table_Name'), 'FieldName', 'IsIdentity')
- Method Two:
Declare @colName varchar(100)Declare @RetColName varchar(100)Set @colName = 'FieldName' --Status column = 128 means its an identity columnSelect @RetColName=[name] from syscolumns where status=128 and id=(select idfrom sysobjects where name='Table_Name')If @colName = @RetColName Print 'Its Identity'Else Print 'Not an identity column'