Primary key information can be obtained from the information schema views. You can either use them "as is" or reverse engineer to something along the lines of select i.name as PK_name ,t_obj.name as Table_name ,col.name as Column_namefrom sysobjects c_obj inner join sysobjects t_obj ON c_obj.parent_obj = t_obj.id inner join syscolumns col ON t_obj.id = col.id cross join master.dbo.spt_values v inner join sysindexes i ON t_obj.id = i.id and c_obj.name = i.name and col.name = index_col(t_obj.name,i.indid,v.number)where c_obj.xtype = 'PK' and t_obj.xtype = 'U' and v.number > 0 and v.type = 'P' and v.number <= i.keycnt
As far as identity column goes, take a look at the syscolumns table, or try columnproperty function.Edited by - izaltsman on 12/31/2001 12:32:25