无法删除表,提示被外键约束引用的解决

原文:http://www.2cto.com/database/201208/149746.html

 SQL

select fk.name,OBJECT_NAME(fk.parent_object_id) as referenceTableName
from sys.foreign_keys as fk
join sys.objects as o on fk.referenced_object_id=o.object_id
where o.name='Category'

 

查找视图的表依赖:

sp_depends '视图名'

http://technet.microsoft.com/zh-cn/library/ms189487(zh-tw,SQL.90).aspx

 

查找存储过程与表的依赖:

select OBJECT_NAME(object_id) as name , OBJECT_NAME(referenced_major_id) as refTable, * 
from sys.sql_dependencies

http://technet.microsoft.com/zh-cn/library/ms174402(v=sql.90).aspx

 

不过 sys.sql_dependencies 官方已经不推荐了,而改用内容更丰富的: sys.sql_expression_dependencies

 http://msdn.microsoft.com/zh-SG/library/bb677315

 

posted @ 2013-04-22 12:01  NewSea  阅读(796)  评论(0编辑  收藏  举报