Groups | Blog | Home
all groups > sql server (microsoft) > june 2005 >

sql server (microsoft) : How do i search all Stored Procedures for a table name


weegee NO[at]SPAM metronet.co.uk
6/20/2005 4:45:58 AM
What I want to do is to search within the text of all Stored Procedures
....for instances of a table name within the SQL
statement

Does anyone know how I would be able to do this?

Say for example I want to search for the table tblContractHistory

Would I use sysobjects?
vchakravarthy NO[at]SPAM datalabusa.com
6/21/2005 7:12:20 AM
Query syscomments or use Enterprise Manager to script out all
procedures to a file and just use simple find (Ctrl-F)
aaron.kempf NO[at]SPAM gmail.com
6/21/2005 9:42:08 AM
or you can use DAO.. as in 'Data Access Objects' in order to enum the
..SQL property of the QueryDef object.

god i wish that MS had just skipped ADO and kept DAO.. i mean.. Data
Access Layer of the month is getting old

-aaron
GP
6/24/2005 3:05:36 PM


Select object_name(id) From syscomments where text like
'%tblContractHistory%'

[quoted text, click to view]
Lloyd Sheen
6/27/2005 5:20:25 PM
That will work most of the time but remember that syscomments will split
words. The only safe way is to reconstitute the source code and then search
in that. That method is much slower but if when you query syscomments you
feel that you are missing something, use the second method.

Lloyd Sheen
[quoted text, click to view]

GP
6/28/2005 6:24:51 AM
<That will work most of the time but remember that syscomments will
split
words>

Can you explain more about this?
AddThis Social Bookmark Button