How do I determine if a column is an identity column in MSSQL 2000?

后端 未结 5 1147
感情败类
感情败类 2021-02-05 01:47

I want to do this in code, not with ALT+F1.

5条回答
  •  一个人的身影
    2021-02-05 02:27

    Adjust the WHERE clause to suit:

    select
        a.name as TableName,
        b.name as IdentityColumn
    from
        sysobjects a inner join syscolumns b on a.id = b.id
    where
        columnproperty(a.id, b.name, 'isIdentity') = 1
        and objectproperty(a.id, 'isTable') = 1
    

提交回复
热议问题