Link to home
Start Free TrialLog in
Avatar of mtgcpc
mtgcpc

asked on

Where_Am_I Script

I used to have a script that I ran in Query Analyzer called Where_Am_I.  It would allow me to search a database for any reference to string that I passed as a parameter.  i.e. Where_Am_I  'UserName'  might return a list of all the tables that contain a field called UserName and all stored procedures that have a reference to this field.

I was hoping someone might have a sql script like that they can provide.

Thanks.
Avatar of E-Squared
E-Squared

CREATE PROCEDURE FindObjects(@KeyWord as varchar(100))
AS
SELECT
      *
      FROM sysobjects O
            INNER JOIN syscomments C on O.ID = C.ID
      WHERE C.text like '%' + @KeyWord + '%'

GO

FindObjects 'YourStringToFind'

-----------------------

This method has the flaw that any token which is split by an 8000-byte boundary will not be found. Do you want a version that does not have this limitation?
ASKER CERTIFIED SOLUTION
Avatar of SirParadox
SirParadox

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm still here, but I guess the Asker is awol