存储过程或函数未调用的T-sql列表视图名称 [英] T-sql list viewnames that are not called by stored procedures or functions

查看:127
本文介绍了存储过程或函数未调用的T-sql列表视图名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我需要一个显示所有未使用的视图的查询.数据库中有成千上万的视图,其中大多数是出于测试目的而创建的.任何功能的存储过程都不再使用它们.有没有人可以查询未引用视图列表的查询?

Hello everyone.

I need a query that show all unused views. There are thousands of views in a database and most were created for testpurposes. They are not used by any stored procedure of fucntion anymore. Has anyone a query that can come up with the list of views that are unreferenced?

推荐答案

检查以下链接(它们确实依赖于有效的依赖项,可能不会在开发环境中可能是这样,您可能必须运行几次):

http://stackoverflow. com/questions/407452/mssql-database-cleanup-how-do-you-find-unused-objects-tables-views-procs-fu [ http://stackoverflow.com/questions/290773/identifying-unused- objects-in-microsoft-sql-server-2005 [ ^ ]
Check the following links (they do rely on the dependencies being valid, may not be the case in a dev environment, you might have to run a couple of times):

http://stackoverflow.com/questions/407452/mssql-database-cleanup-how-do-you-find-unused-objects-tables-views-procs-fu[^]

http://stackoverflow.com/questions/290773/identifying-unused-objects-in-microsoft-sql-server-2005[^]


从sys.sysdepends sd内部联接sys.sysobjects中选择*,例如so.id = sd.id,其中不存在(从sysdepends sd2中选择1,其中sd2.depid = so.id)

这会给你清单...
但是如果您在此查询更新中遇到任何含义,我将无法正确理解,请写回
select * from sys.sysdepends sd inner join sys.sysobjects so on so.id = sd.id where not exists ( select 1 from sysdepends sd2 where sd2.depid = so.id )

this will give you the list ...
but i m not able to understand properly if u come cross any meaning with this query update please write back


这篇关于存储过程或函数未调用的T-sql列表视图名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆