declare @sql nvarchar(500)
declare @TblName nvarchar(100)
set @TblName = 'FaxRecvHistory'
set @sql = ''
--附在主键上的表
set @sql = N'select name from sysobjects where xtype=''U''' +
' and object_id(name) in(' +
' select fkeyid from sysforeignkeys where rkeyid=object_id( +
' )'
exec sp_executesql @sql
--外键依赖
set @sql = N'select name from sysobjects where xtype=''U''' +
' and object_id(name) in( ' +
' select rkeyid from sysforeignkeys where fkeyid=object_id(''' + @TblName + ''')' +
' )'
exec sp_executesql @sql
阅读(1231) | 评论(0) | 转发(0) |