Create a sample table with an identity column in it.Create table [order_details](OrderId int identity,OrderName varchar(10),UnitPrice int)
Select ColumnProperty(Object_id('order_details'), 'OrderId', 'IsIdentity')
Declare @colName varchar(100)Declare @RetColName varchar(100)Set @colName = 'OrderId' -- Specify the column name for which you want to check--Status column = 128 means its an identity columnSelect @RetColName=[name] from syscolumns where (status & 128) = 128 and id=(select idfrom sysobjects where name='order_details')If @colName = @RetColNamePrint 'Its Identity'ElsePrint 'Not an identity column'