如何识别引用特定表的所有存储过程 [英] How to identify all stored procedures referring a particular table

查看:23
本文介绍了如何识别引用特定表的所有存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为测试目的创建了一个关于开发环境的表,很少有 sp 会引用这个表.现在我必须删除这个表,并确定所有引用这个表的 sp.我很难找到所有 sp 的列表.请假设表名为x",数据库为 sql server 2005,提出一些查询建议.

I created a table on development environment for testing purpose and there are few sp's which are refreing this table. Now I have have to drop this table as well as identify all sp's which are referring this table. I am facing difficulty to find list of all sp's. Please suggest some query by assuming that the table name is 'x' and database is sql server 2005.

推荐答案

SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%TableNameOrWhatever%'

顺便说一句——这里是这类问题的一个方便的资源:查询 SQL Server 系统目录常见问题

BTW -- here is a handy resource for this type of question: Querying the SQL Server System Catalog FAQ

这篇关于如何识别引用特定表的所有存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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