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.
| Author |
Topic |
|
monkeybite
Posting Yak Master
152 Posts |
Posted - 2004-07-30 : 17:32:03
|
| Anyone know of a way to find all identity columns in a database?INFORMATION_SCHEMA.Columns doesn't seem to indicate them in any way. Looking at syscolumns, seems that the autoval column might be the one to check.Thanks~ monkey |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-07-30 : 17:50:26
|
| select o.name, c.namefrom sysobjects oinner join syscolumns con o.id = c.idwhere columnproperty(o.id, c.name, 'IsIdentity') = 1order by o.nameTara |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-07-30 : 17:52:29
|
| No join needed:SELECT OBJECT_NAME(id) AS TableName, name AS ColumnNameFROM syscolumnsWHERE COLUMNPROPERTY(id, name, 'IsIdentity') = 1ORDER BY OBJECT_NAME(id)Tara |
 |
|
|
monkeybite
Posting Yak Master
152 Posts |
Posted - 2004-07-30 : 17:53:42
|
| Nice. forgot about that function COLUMNPROPERTY(). Thanks!~ monkey |
 |
|
|
|
|
|