How do you determine what SQL Tables have an identity column programmatically

后端 未结 13 1969
借酒劲吻你
借酒劲吻你 2020-11-30 23:44

I want to create a list of columns in SQL Server 2005 that have identity columns and their corresponding table in T-SQL.

Results would be something like:

Tab

相关标签:
13条回答
  • 2020-12-01 00:30

    List of tables without Identity column based on Guillermo answer:

    SELECT DISTINCT TABLE_NAME
    FROM            INFORMATION_SCHEMA.COLUMNS
    WHERE        (TABLE_SCHEMA = 'dbo') AND (OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 0)
    ORDER BY TABLE_NAME
    
    0 讨论(0)
提交回复
热议问题