在SQL Server数据库中查找对对象的所有引用 [英] Find all references to an object in an SQL Server database
问题描述
我试图在SQL Server数据库中找到对一个对象的所有引用.
I'm trying to find all references to an object in an SQL Server database.
如何快速搜索? SQL Server Management Studio似乎没有这样做.我使用 http://www.red-gate.com/products/SQL_Search/但是我想找到对此的官方" Microsoft解决方案.是在另一种产品中吗?
How can I quickly search? SQL Server Management Studio does not seem to do it. I use http://www.red-gate.com/products/SQL_Search/ but I'd like to find the "official" Microsoft solution to this. Is it in another product?
例如,当我在Visual Studio中进行批量搜索时,我希望也能在所有存储过程中找到一些东西.
For example, when I do a mass search in visual studio, I would like to be able to also find something in all stored procedures.
或者也许我的编码方式不正确?
Or maybe I'm not coding this the right way?
卡尔
推荐答案
使用:
select object_name(m.object_id), m.*
from sys.sql_modules m
where m.definition like N'%name_of_object%'
...因为SYSCOMMENTS
和INFORMATION_SCHEMA.routines
具有nvarchar(4000)列.因此,如果在位置3998处使用"name_of_object",则找不到该名称. SYSCOMMENTS
确实有多行,但INFORMATION_SCHEMA.routines
会被截断.
...because SYSCOMMENTS
and INFORMATION_SCHEMA.routines
have nvarchar(4000) columns. So if "name_of_object" is used at position 3998, it won't be found. SYSCOMMENTS
does have multiple lines, but INFORMATION_SCHEMA.routines
truncates.
这篇关于在SQL Server数据库中查找对对象的所有引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!