What 's the way to know
the name of the column that is
the primary key of a tableTry this one:
select 'Table ['+su.name+'.'+so.name+']',sc.name
from sysindexes sy
join sysobjects so on so.id=sy.id and so.xtype='U'
join sysusers su on su.uid=so.uid
join sysindexkeys si on si.id=so.id and si.indid=sy.indid
join syscolumns sc on sc.id=so.id and sc.colid=si.colid
join sysobjects sop on sop.parent_obj=so.id and sop.xtype='PK' and sop.name=sy.name
where sy.indid not in(0,255)|||Thank you
forgot that existed sysindexes|||Thank you very much
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment