Here is something see if this is what you are looking for...Replace the text
Jason with whatever text you are looking for.
SELECT OBJECT_NAME(c1.id) AS name, SUBSTRING(c1.text, CHARINDEX('Jason',
c1.text) - 5, 60) AS text
FROM syscomments c1 LEFT OUTER JOIN
syscomments c2 ON c1.id = c2.id AND c2.number =
c1.number + 1
WHERE (CAST(c1.text AS varchar(4000)) + COALESCE (CAST(c2.text AS
varchar(4000)), '') LIKE '%Jason%')
-----Original Message-----
From: Adam Blumenfeld
[mailto:mssqldba-ezmlmshield-x67446912.[Email address protected]
Sent: Thursday, June 28, 2007 11:31 AM
To: LazyDBA Discussion
Subject: Query to search for text...
Does anyone have a piece of code that takes, as a parameter, for
instance, the name of a table, or field, etc... and looks through system
tables, and returns the name of every object that lists that inputted
table name or field name, etc...
For instance, I could search for a field name, and the code would return
every table that had that field name in it, and ever stored procedure
and view that mentioned that field name...
Adam Blumenfeld
############################################################################
#########
Warning:
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to which it is addressed. If
you are not the named addressee any review, dissemination, distribution or
duplication of this e-mail is strictly prohibited. If you have received this
email in error, please let us know by e-mail and delete it from your system.
Please note that any personal views or opinions presented in this email are
solely those of the author and do not necessarily represent those of the
company.
Thank You.
############################################################################
#########
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
MS Sql Server LazyDBA home page