有没有什么方法可以针对它访问的表和列来检查 TSQL 过程?

Is there any way to introspect a TSQL procedure for tables and columns accessed by it?

我发现自己需要记录 SQL 服务器中大量存储过程访问的所有表和列。我可以搜索正文中有这个或那个文本的存储过程,但这不是我所需要的。

有很多方法可以找到存储过程依赖项。粗略 google 搜索将使您找到:

https://msdn.microsoft.com/en-us/library/ms345404.aspx

Using SQL Server Management Studio

To view the dependencies of a procedure in Object Explorer

In Object Explorer, connect to an instance of Database Engine and then expand that instance.

Expand Databases, expand the database in which the procedure belongs, and then expand Programmability.

Expand Stored Procedures, right-click the procedure and then click View Dependencies.

View the list of objects that depend on the procedure.

View the list of objects on which the procedure depends.

Click OK.

或使用SQL:

SELECT referencing_schema_name, referencing_entity_name, referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('table name', 'OBJECT'); 

等等

要执行 所有 存储过程,您可以在 sys.object 上编写连接以插入上面列出的 DMV,并进行一些潜在的调整...但它绝对可行.认为可能还有一些 SSMS 插件可以做到这一点。也许是红门?