Here is some code to get a list of identity columns in database.
select so.name as TableName, + o.list as IdentityColumnName
from sysobjects so
cross apply
(SELECT
column_name
+
case when exists (
select id from syscolumns
where object_name(id)=so.name
and name=column_name
and columnproperty(id,name,'IsIdentity') = 1
) then
''
end + ' '
from information_schema.columns where table_name = so.name
) o (list)
where xtype = 'U'
AND o.list is not null
AND name NOT IN ('dtproperties')
posted @ Monday, November 11, 2013 4:14 PM