Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Searching Identity columns

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-09-21 : 10:41:25
Guys,
I am trying search for all the columns in the database that have identity property.
I ve tried to search by querying information_schema.columns but could get the results that I wanted.

Any better ideas/suggestions would certainly help.

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-21 : 13:03:20
You'll need to use the COLUMNPROPERTY function.

SELECT COLUMNPROPERTY (OBJECT_ID('TableNameGoesHere'), 'ColumnNameGoesHere', IsIdentity)


Tara
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-22 : 01:47:28
SELECT table_name, column_name as Identity_Column
FROM information_schema.columns
WHERE COLUMNPROPERTY(OBJECT_ID(table_name),column_name,'IsIdentity')=1
order by table_name


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -