SQL Server 2005 List all IDENTITY columns

SQL Server 2005

Here is a simple bit of T-SQL that will display the names of all the IDENTITY columns in a database:

SELECT SCHEMA_NAME( OBJECTPROPERTY( OBJECT_ID, 'SCHEMAID' )) AS SCHEMA_NAME,
      OBJECT_NAME( OBJECT_ID ) AS TABLE_NAME,
      NAME AS COLUMN_NAME
FROM  SYS.COLUMNS
WHERE COLUMNPROPERTY(OBJECT_ID, NAME, 'IsIdentity') = 1

What's Related

Story Options

Trackback

Trackback URL for this entry: http://www.julian-kuiters.id.au/trackback.php/sql-server-2005-find-identity-columns

No trackback comments for this entry.
SQL Server 2005 List all IDENTITY columns | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.


Gold Coast Aquarium Maintenance | Gold Coast Marine Fish | Gold Coast Tropical Fish
 
     
 Copyright © 2010 Julian Kuiters
 All trademarks and copyrights on this page are owned by their respective owners.