I'm trying to find all references to an object in an SQL Server database.
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?
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?
Carl
To view the objects on which a table depends. In Object Explorer, expand Databases, expand a database, and then expand Tables. Right-click a table, and then click View Dependencies.
Search object using SSMS object explorer detailsNavigate to View-> Object Explorer Details in SSMS. You can use a keyboard shortcut F7 to open it. It opens the following screen and shows the various folders – Databases, Security, Server objects, Replication, PolyBase, Always on High Availability.
Use:
select object_name(m.object_id), m.* from sys.sql_modules m where m.definition like N'%name_of_object%'
...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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With