Sybase 查看与目标表有外键关联的表名称

目标表为:TestTable

select sysobjects.name FK_Name,a.*
from 
(select constrid,sysreferences.tableid,a.name as tablename,sysreferences.reftabid,b.name as reftabname
	from sysreferences
   LEFT OUTER join sysobjects a on sysreferences.tableid = a.id
   LEFT OUTER join sysobjects b on sysreferences.reftabid = b.id  ) a,
sysobjects
where a.constrid = sysobjects.id
  and (tableid = object_id('TestTable') or reftabid=object_id('TestTable'))

你可能感兴趣的:(Sybase)