How to find Identity Column in SQL Server?


Find Identity Column in SQL Server Database.
Example:

Create table #Temp
(
  ID  int identity(1,1) ,
  EmployeeName varchar(100),
  Age int  
)

Insert into #Temp(EmployeeName,Age)
Select 'Hitesh',25 union
Select 'Priyanka',23 union
Select 'Dev',33 union
Select 'Neha',25 union
Select 'Abhimanyu',22 union
Select 'Bhawesh',30


SQL Query to get Identity Column Name

Select $identity from #Temp(Nolock) where 1=0


Result: ID
SQL Query to get Identity Column Value

Select $identity from #Temp(Nolock)


Result:
ID
1
2
3
4
5
6