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
If you want to use OMG Ponies sql as a keyboard shortcut in SSMS, add the following SP to your master db.
Then you just need to add dbo.SP_FindAllReferences to your keyboard shortcuts and then you can use it in the context of any DB on your server.
Cheers!
NB: If you are using SQL Server 2005 you will have to replace
with
I'm not sure of 'official microsoft' way but I've used SqlDigger in the past. It's not bad.
If you want to do it in VS, then you will need the text of all your procs included in your project.
SQL Server Management Studio has a View Dependencies feature when you right click on an object in the Object Explorer. Is this what you're looking for?
In SQL Server 2000 here is a query that can search inside object definitions, supporting search strings of up to 2000 characters. It uses the chunks in the
syscomments
table.With the use of an undocumented SQL sp: sp_msforeachdb
I found a solution like this..
http://blog.sqlauthority.com/2012/12/02/sql-server-find-referenced-or-referencing-object-in-sql-server-using-sys-sql_expression_dependencies/