SQL 2000
SELECT
c.TABLE_NAME
,c.COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS c
WHERE COLUMNPROPERTY(OBJECT_ID(c.TABLE_NAME),c.COLUMN_NAME,'IsIdentity') = 1
SQL 2005/2008
SELECT OBJECT_NAME(Object_Id) AS Table_name,
Name AS COLUMN_NAME
FROM sys.identity_columns
for getting identity columns in table just filter on table name value
No comments:
Post a Comment