• Are you looking for a particular part of code? There is no good way to do this other than what you've noted. SQL Server doesn't index or track code in any way. If you need to find if a particular piece of code exists, you'll have to search each database.

    If you are looking for a particular object being used, as in a dependency, sys.depends exists, but it isn't reliable. Really any tool, such as SQL Compare, that needs to determine dependencies, must build a tree by searching all objects.

    Disclosure: I work for Redgate Software, maker of SQL Compare.