sp_fkeys this sp should return all the foreign keys. You try it: sp_fkeys @pktable_name = N'tablename' try it:)
select * from sysobjects where id in ( select constid from sysforeignkeys inner join sysobjects on fkeyid=id where name='table1' )exec sp_pkeys table1 exec sp_fkeys table1SELECT * FROM sysobjects WHERE (name = (SELECT name FROM sysindexes WHERE (id = OBJECT_ID('table1')) AND (indid = (SELECT indid FROM sysindexkeys WHERE (id = OBJECT_ID('table1')) AND (colid = (SELECT colid FROM syscolumns WHERE (id = OBJECT_ID('table1')) AND (name = 'a'))))))) AND (xtype = 'PK')
this sp should return all the foreign keys. You try it:
sp_fkeys @pktable_name = N'tablename'
try it:)
where id
in (
select constid from sysforeignkeys inner join sysobjects
on fkeyid=id
where name='table1'
)exec sp_pkeys table1
exec sp_fkeys table1SELECT *
FROM sysobjects
WHERE (name =
(SELECT name
FROM sysindexes
WHERE (id = OBJECT_ID('table1')) AND (indid =
(SELECT indid
FROM sysindexkeys
WHERE (id = OBJECT_ID('table1')) AND (colid =
(SELECT colid
FROM syscolumns
WHERE (id = OBJECT_ID('table1')) AND (name = 'a'))))))) AND
(xtype = 'PK')